[Lldb-commits] [lldb] r245436 - On Linux, clear the signal mask of the launched inferior

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Wed Aug 19 06:47:57 PDT 2015

Author: labath
Date: Wed Aug 19 08:47:57 2015
New Revision: 245436

URL: http://llvm.org/viewvc/llvm-project?rev=245436&view=rev
On Linux, clear the signal mask of the launched inferior

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().

Patch by: Yacine Belkadi

Reviewers: ovyalov, labath

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D12138


Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp?rev=245436&r1=245435&r2=245436&view=diff
--- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp Wed Aug 19 08:47:57 2015
@@ -554,7 +554,8 @@ NativeProcessLinux::Launch(LaunchArgs *a
-        eSetGidFailed
+        eSetGidFailed,
+        eSetSigMaskFailed
     // Child process.
@@ -632,6 +633,12 @@ NativeProcessLinux::Launch(LaunchArgs *a
+        // 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),
@@ -689,6 +696,9 @@ NativeProcessLinux::Launch(LaunchArgs *a
             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.");

Modified: lldb/trunk/test/expression_command/call-restarts/TestCallThatRestarts.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/call-restarts/TestCallThatRestarts.py?rev=245436&r1=245435&r2=245436&view=diff
--- lldb/trunk/test/expression_command/call-restarts/TestCallThatRestarts.py (original)
+++ lldb/trunk/test/expression_command/call-restarts/TestCallThatRestarts.py Wed Aug 19 08:47:57 2015
@@ -29,7 +29,6 @@ class ExprCommandThatRestartsTestCase(Te
     @skipIfFreeBSD # llvm.org/pr19246: intermittent failure
-    @expectedFailureLinux("llvm.org/pr19246")
     @skipIfDarwin # llvm.org/pr19246: intermittent failure
     @skipIfWindows # Test relies on signals, unsupported on Windows
     def test_with_dwarf(self):

More information about the lldb-commits mailing list