]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix bug 72484. Set the process signal mask to match the client's before
authorJeremy Fitzhardinge <jeremy@valgrind.org>
Fri, 16 Jan 2004 02:17:30 +0000 (02:17 +0000)
committerJeremy Fitzhardinge <jeremy@valgrind.org>
Fri, 16 Jan 2004 02:17:30 +0000 (02:17 +0000)
running exec.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2198

coregrind/vg_include.h
coregrind/vg_syscalls.c
none/tests/Makefile.am
none/tests/exec-sigmask.stderr.exp [new file with mode: 0644]

index 4bfa7643f7475a735c3866d88364c52af368c730..8681485ba79c7600aad22f8ae97fd3fd4d72328b 100644 (file)
@@ -764,8 +764,8 @@ typedef
    */
    vki_ksigset_t sig_mask;
 
-   /* Effective signal mask.  This is the mask which is currently
-      applying; it may be different from sig_mask while a signal
+   /* Effective signal mask.  This is the mask which currently
+      applies; it may be different from sig_mask while a signal
       handler is running.
     */
    vki_ksigset_t eff_sig_mask;
index d123eec980c1c7f402b250876adc947a00472bbe..1e4fe2517121977c80949a4d814fcd1b370b193b 100644 (file)
@@ -1877,6 +1877,29 @@ PRE(execve)
         VG_(printf)("env: %s\n", *cpp);
    }
 
+   /* Set our real sigmask to match the client's sigmask so that the
+      exec'd child will get the right mask.  First we need to clear
+      out any pending signals so they they don't get delivered, which
+      would confuse things.
+
+      XXX This is a bug - the signals should remain pending, and be
+      delivered to the new process after exec.  There's also a
+      race-condition, since if someone delivers us a signal between
+      the sigprocmask and the execve, we'll still get the signal. Oh
+      well.
+   */
+   {
+      vki_ksigset_t allsigs;
+      vki_ksiginfo_t info;
+      static const struct vki_timespec zero = { 0, 0 };
+    
+      VG_(ksigfillset)(&allsigs);
+      while(VG_(ksigtimedwait)(&allsigs, &info, &zero) > 0)
+        ;
+
+      VG_(ksigprocmask)(VKI_SIG_SETMASK, &tst->sig_mask, NULL);
+   }
+
    res = VG_(do_syscall)(__NR_execve, arg1, arg2, arg3);
 
    /* If we got here, then the execve failed.  We've already made too much of a mess
index e75d284b50e6353865ab516c50548f0acb3faac0..0dd6e895799a07a7baa1037b634a0de775c1c032 100644 (file)
@@ -15,6 +15,8 @@ EXTRA_DIST = $(noinst_SCRIPTS) \
        dastest.vgtest \
        discard.stderr.exp discard.stdout.exp \
        discard.vgtest \
+       exec-sigmask.vgtest 
+       exec-sigmask.stdout.exp exec-sigmask.stderr.exp \
        floored.stderr.exp floored.stdout.exp \
        floored.vgtest \
        fork.stderr.exp fork.stdout.exp fork.vgtest \
@@ -44,7 +46,7 @@ EXTRA_DIST = $(noinst_SCRIPTS) \
 
 check_PROGRAMS = \
        args bitfield1 bt_everything bt_literal coolo_strlen \
-       cpuid dastest discard floored fork fpu_lazy_eflags \
+       cpuid dastest discard exec-sigmask floored fork fpu_lazy_eflags \
        fucomip munmap_exe map_unmap mremap rcl_assert \
        rcrl readline1 resolv seg_override sha1_test shortpush shorts smc1 \
        pth_blockedsig \
@@ -63,6 +65,7 @@ cpuid_SOURCES                 = cpuid_c.c cpuid_s.s
 coolo_strlen_SOURCES   = coolo_strlen.c
 dastest_SOURCES        = dastest_c.c dastest_s.s
 discard_SOURCES        = discard.c
+exec_sigmask_SOURCES   = exec-sigmask.c
 fork_SOURCES           = fork.c
 floored_SOURCES        = floored.c
 floored_LDADD          = -lm
diff --git a/none/tests/exec-sigmask.stderr.exp b/none/tests/exec-sigmask.stderr.exp
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+