fork - GDB and LLDB "swallow" status set by child process in OS X -


given following code:

#include <stdio.h> #include <signal.h> #include <unistd.h> #include <sys/wait.h>  int main(int ac, char** av) {     int status;     pid_t cpid = fork();     if(0 == cpid) { /* child */         return *(volatile int*) 0; /* exits signal 11 */     } else { /* parent */         {             waitpid(cpid, &status, wuntraced);             if(wifsignaled(status)) {                 printf("\nchild exited signal %d\n\n", wtermsig(status));                 return 0;             }         } while (!wifexited(status) && !wifsignaled(status));         printf("\nchild exited normally\n\n");     }     return 0; } 

i expected result running app terminal:

$ ./fork4gdbtests.exe  child exited signal 11 

running app within lldb (or gdb), strangely, get:

$ lldb ./fork4gdbtests.exe (lldb) target create "./fork4gdbtests.exe" current executable set './fork4gdbtests.exe' (x86_64). (lldb) r process 46815 launched: './fork4gdbtests.exe' (x86_64)  child exited  process 46815 exited status = 0 (0x00000000)  

my makefile looks (used cygwin, also):

cc = gcc cflags = -wextra -wall -werror -wno-unused-parameter -g .phony: clean all: fork4gdbtests.exe %.exe: %.o     $(cc) $(cflags) $? $(libs) -o $@ clean:     rm -f *.o *.exe *.stackdump; 

in cygwin, expected result both running command prompt , in debugger. similar behavior occurs kinds of other signals, such sigfpe or signals sent child means of kill().

what going on?

that's bug. given affects both gdb & lldb in coreos not debuggers (though same folks did mach specific layer of both debuggers that's not guarantee...)

anyway, please file bug report http://bugreporter.apple.com.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -