Add support for ioctl(fd, TIOCSIG, signal_number) which used
to issue a false complaint. Fixes BZ #339706
Source patch by David Herrmann (dh.herrmann@gmail.com).
Testcase by myself.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14646 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/NEWS b/NEWS
index c99ed30..f1d76c9 100644
--- a/NEWS
+++ b/NEWS
@@ -42,6 +42,7 @@
 339688 Mac-specific ASM does not support .version directive (cpuid,
        tronical and pushfpopf tests)
 
+339706 Fix false positive for ioctl(TIOCSIG) on linux
 339721 assertion 'check_sibling == sibling' failed in readdwarf3.c ...
 339789 Fix none/tests/execve test on Mac OS X 10.9
 339808 Fix none/tests/rlimit64_nofile test on Mac OS X 10.9
diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c
index 9253947..99091a0 100644
--- a/coregrind/m_syswrap/syswrap-linux.c
+++ b/coregrind/m_syswrap/syswrap-linux.c
@@ -5481,6 +5481,7 @@
    case VKI_TCXONC:
    case VKI_TCSBRKP:
    case VKI_TCFLSH:
+   case VKI_TIOCSIG:
       /* These just take an int by value */
       break;
    case VKI_TIOCGWINSZ:
@@ -8270,6 +8271,7 @@
    case VKI_TCXONC:
    case VKI_TCSBRKP:
    case VKI_TCFLSH:
+   case VKI_TIOCSIG:
       break;
    case VKI_TIOCGWINSZ:
       POST_MEM_WRITE( ARG3, sizeof(struct vki_winsize) );
diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h
index 2d81e3f..9dadf58 100644
--- a/include/vki/vki-linux.h
+++ b/include/vki/vki-linux.h
@@ -2955,6 +2955,10 @@
 #define VKI_FIOQSIZE 0x5460     /* Value differs on some platforms */
 #endif
 
+#ifndef VKI_TIOCSIG
+#define VKI_TIOCSIG _VKI_IOW('T', 0x36, int) /* Value differs on some platforms */
+#endif
+
 //----------------------------------------------------------------------
 // From kernel/common/include/linux/ashmem.h
 //----------------------------------------------------------------------
diff --git a/memcheck/tests/linux/Makefile.am b/memcheck/tests/linux/Makefile.am
index 9755f5c..d8a7d4d 100644
--- a/memcheck/tests/linux/Makefile.am
+++ b/memcheck/tests/linux/Makefile.am
@@ -6,6 +6,7 @@
 EXTRA_DIST = \
 	brk.stderr.exp brk.vgtest \
 	capget.vgtest capget.stderr.exp capget.stderr.exp2 \
+	ioctl-tiocsig.vgtest ioctl-tiocsig.stderr.exp \
 	lsframe1.vgtest lsframe1.stdout.exp lsframe1.stderr.exp \
 	lsframe2.vgtest lsframe2.stdout.exp lsframe2.stderr.exp \
 	rfcomm.vgtest rfcomm.stderr.exp \
@@ -24,6 +25,7 @@
 check_PROGRAMS = \
 	brk \
 	capget \
+	ioctl-tiocsig \
 	getregset \
 	lsframe1 \
 	lsframe2 \
diff --git a/memcheck/tests/linux/ioctl-tiocsig.c b/memcheck/tests/linux/ioctl-tiocsig.c
new file mode 100644
index 0000000..1738066
--- /dev/null
+++ b/memcheck/tests/linux/ioctl-tiocsig.c
@@ -0,0 +1,7 @@
+#include <sys/ioctl.h>
+
+int main()
+{
+   ioctl(9, TIOCSIG, 9);
+   return 0;
+}
diff --git a/memcheck/tests/linux/ioctl-tiocsig.stderr.exp b/memcheck/tests/linux/ioctl-tiocsig.stderr.exp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/memcheck/tests/linux/ioctl-tiocsig.stderr.exp
diff --git a/memcheck/tests/linux/ioctl-tiocsig.vgtest b/memcheck/tests/linux/ioctl-tiocsig.vgtest
new file mode 100644
index 0000000..2e75ad5
--- /dev/null
+++ b/memcheck/tests/linux/ioctl-tiocsig.vgtest
@@ -0,0 +1,2 @@
+prog: ioctl-tiocsig
+vgopts: -q