On Unix and Linux systems, the status returned from wait
or waitpid
(or any of the other wait
variants) has this structure:
bits meaning
0-6 signal number that caused child to exit,
or 0177 if child stopped / continued
or zero if child exited without a signal
7 1 if core dumped, else 0
8-15 low 8 bits of value passed to _exit/exit or returned by main,
or signal that caused child to stop/continue
(Note that Posix doesn't define the bits, just macros, but these are the bit definitions used by at least Linux, Mac OS X/iOS, and Solaris. Also note that waitpid
only returns for stop events if you pass it the WUNTRACED
flag and for continue events if you pass it the WCONTINUED
flag.)
So a status of 11 means the child exited due to signal 11, which is SIGSEGV
(again, not Posix but conventionally).
Either your program is passing invalid arguments to execv
(which is a C library wrapper around execve
or some other kernel-specific call), or the child runs differently when you execv
it and when you run it from the shell or gdb.
If you are on a system that supports strace
, run your (parent) program under strace -f
to see whether execv
is causing the signal.