I\'m currently making a command line app in C in which many child process is created. So I need to debug this children code. I have created a child process on Xcode as follo
Google and Apple developer page are really silent on this issue and finally I've found a good workaround. This error message appears when we get Xcode debugger to attach to the process that is a child process of process being debugged or that is a process already being debugged by Xcode debugger, gdb, or lldb.
In order to avoid this irritating message, First put kill(0, SIGSTOP)
statement where you want to stop the child process. In the following figure, I have put the kill
statement right after the child is created.
Second, use gcc
to compile your source codes with -g option.
$ ls
GBN.1 gbn.c gbn.h type.h util.c util.h
$ gcc *.c -g
$ ./a.out
[1]+ Stopped ./a.out
$ ps -ef | grep a.out
501 628 600 0 9:33AM ttys000 0:00.00 ./a.out
501 629 628 0 9:33AM ttys000 0:00.00 ./a.out
Now, all we have to do is to tell Xcode debugger to attach to the process by pid. Click the Debug
menu and then find the Attach to process
option to click By Process Identifier (PID) or name
option. Then type the pid for child process (or parent process) and click attach button.
Enjoy Debugging!