[Lldb-commits] [PATCH] D12138: On Linux, clear the signal mask of the launched inferior

Yacine Belkadi via lldb-commits lldb-commits at lists.llvm.org
Tue Aug 18 23:44:58 PDT 2015

ybelkadi created this revision.
ybelkadi added reviewers: labath, ovyalov.
ybelkadi added a subscriber: lldb-commits.

Due to fork()/execve(), the launched inferior inherits the signal mask of its parent (lldb-server). But because lldb-server modifies its signal mask (It blocks SIGCHLD, for example), the inferior starts with some signals being initially blocked.

One consequence is that TestCallThatRestarts.ExprCommandThatRestartsTestCase (test/expression_command/call-restarts) fails because sigchld_handler() in lotta-signals.c is not called, due to the SIGCHLD signal being blocked.

To prevent the signal masking done by lldb-server from affecting the created inferior, the signal mask of the inferior is now cleared before the execve().



Index: source/Plugins/Process/Linux/NativeProcessLinux.cpp
--- source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -554,7 +554,8 @@
-        eSetGidFailed
+        eSetGidFailed,
+        eSetSigMaskFailed
     // Child process.
@@ -629,6 +630,12 @@
+        // Clear the signal mask to prevent the child from being affected by
+        // any masking done by the parent.
+        sigset_t set;
+        if (sigemptyset(&set) != 0 || pthread_sigmask(SIG_SETMASK, &set, nullptr) != 0)
+            exit(eSetSigMaskFailed);
         // Execute.  We should never return...
                const_cast<char *const *>(argv),
@@ -686,6 +693,9 @@
             case eSetGidFailed:
                 error.SetErrorString("Child setgid failed.");
+            case eSetSigMaskFailed:
+                error.SetErrorString("Child failed to set signal mask.");
+                break;
                 error.SetErrorString("Child returned unknown exit status.");

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12138.32506.patch
Type: text/x-patch
Size: 1283 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150819/d94a90e5/attachment.bin>

More information about the lldb-commits mailing list