@@ -2000,7 +2000,21 @@ Status NativeProcessAIX::PtraceWrapper(int req, lldb::pid_t pid, void *addr,
2000
2000
} else if (req == PT_WRITE_BLOCK) {
2001
2001
ptrace64 (req, pid, (long long )addr, (int )data_size, (int *)result);
2002
2002
} else if (req == PT_ATTACH) {
2003
+ // Block SIGCHLD signal during attach to the process,
2004
+ // to prevent interruptions.
2005
+ // The ptrace operation may send SIGCHLD signals in certain cases
2006
+ // during the attach, which can interfere.
2007
+ static sigset_t signal_set;
2008
+ sigemptyset (&signal_set);
2009
+ sigaddset (&signal_set, SIGCHLD);
2010
+ if (!pthread_sigmask ( SIG_BLOCK, &signal_set, NULL ))
2011
+ LLDB_LOG (log," NativeProcessAIX::pthread_sigmask(SIG_BLOCK) Failed" );
2012
+
2003
2013
ptrace64 (req, pid, 0 , 0 , nullptr );
2014
+
2015
+ // Unblocking the SIGCHLD after attach work.
2016
+ if (!pthread_sigmask ( SIG_UNBLOCK, &signal_set, NULL ))
2017
+ LLDB_LOG (log," NativeProcessAIX::pthread_sigmask(SIG_UNBLOCK) Failed" );
2004
2018
} else if (req == PT_WATCH) {
2005
2019
ptrace64 (req, pid, (long long )addr, (int )data_size, nullptr );
2006
2020
} else if (req == PT_DETACH) {
0 commit comments