SIGSEGV after vfork()

Project BRAVO (bravo@russell.ce.uniroma2.it)
Fri, 19 Mar 1999 19:01:55 +0100


The program attached below causes a SIGSEGV signal in parent, no matter
of what child does (exit() or execve()).

If the wrapper routine vfork() is made inline, the fault does not occur;
however, the fault always occurs if ``exit(0)'' is replaced by ``return''.
In short:

exit return

inline ok fault
not inline fault fault

Linux 2.2.3 libc-5.4.46 gcc-2.7.2.3
Linux 2.2.2 libc-2.0.7 gcc-2.7.2.3

Am I missing something? Is it a kernel problem?

Marco Cesati

#include <stdio.h>
#include <unistd.h>
#include <linux/unistd.h>

#undef vfork
_syscall0(int, vfork)

/* alternatively, define
int inline vfork(void) { ... }
*/

void main(void)
{
int child;

printf("Parent PID: %d\n", getpid());
if ((child = vfork()) == -1) exit(1);
if (!child) {
printf("[%d] I'm a child\n", getpid());
sleep(1);
return;
}
printf("[%d] New child has PID %d\n", getpid(), child);
exit(0); /* return; */
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/