Change debugserver to spawn processes in their own pgrp
authorJason Molenda <jason@molenda.com>
Thu, 24 Nov 2022 18:56:01 +0000 (10:56 -0800)
committerJason Molenda <jason@molenda.com>
Thu, 24 Nov 2022 18:59:12 +0000 (10:59 -0800)
Change debugserver's posix_spawn() to spawn an inferior process in
its own process group, so signals from the terminal like control-c
are passed to the inferior process instead of debugserer.  In lldb's
own native-host launching, there is a LaunchInfo option
LaunchInSeparateProcessGroup, and this mirrors the most common
setting of that on Darwin systems.

Patch by Alessandro Arzilli <alessandro.arzilli@gmail.com>.

Differential Revision: https://reviews.llvm.org/D128504

lldb/tools/debugserver/source/MacOSX/MachProcess.mm

index 70a8ecd..8f3d200 100644 (file)
@@ -3307,7 +3307,7 @@ pid_t MachProcess::PosixSpawnChildForPTraceDebugging(
     return INVALID_NUB_PROCESS;
 
   flags = POSIX_SPAWN_START_SUSPENDED | POSIX_SPAWN_SETSIGDEF |
-          POSIX_SPAWN_SETSIGMASK;
+          POSIX_SPAWN_SETSIGMASK | POSIX_SPAWN_SETPGROUP;
   if (disable_aslr)
     flags |= _POSIX_SPAWN_DISABLE_ASLR;