Ignore SIGTRAP in child process on macOS
When running gn under Xcode (e.g. when debugging), the child process
is sent a SIGTRAP signal and immediately dies as it is not handled.
This makes gn consider that action, action_foreach and exec_script
have failed due to the signalled state of the child process.
To prevent this, ignore the SIGTRAP signal on macOS in the child
process.
Bug: none
Change-Id: Ic28312939d646db7d49c767d37566f3a8ed2c923
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/6662
Reviewed-by: Brett Wilson <brettw@chromium.org>
Commit-Queue: Brett Wilson <brettw@chromium.org>
diff --git a/src/gn/exec_process.cc b/src/gn/exec_process.cc
index eeebcb4..2f001bf 100644
--- a/src/gn/exec_process.cc
+++ b/src/gn/exec_process.cc
@@ -204,6 +204,13 @@
return false;
case 0: // child
{
+#if defined(OS_MAC)
+ // When debugging the app under Xcode, the child will receive a SIGTRAP
+ // signal which will terminate the child process. Ignore the signal to
+ // allow debugging under macOS.
+ sigignore(SIGTRAP);
+#endif
+
// DANGER: no calls to malloc are allowed from now on:
// http://crbug.com/36678
//