Running a trivial program within gdb, that forks and execl a client. The execl line (while inside inferior 2 in gdb) gives the process ID "is executing new program" and then immediately seg faults.
Code to that point follows:
int main(int argc, char *argv[] ) {
/* Create socket pair for communication with server, and fork/exec the server code */
int ret;
int fd[2];
ret = socketpair( AF_LOCAL, SOCK_STREAM | SOCK_NONBLOCK, 0, fd );
if( ret < 0 ) {
perror( "Unable to create initial socketpair for qrServer" );
return -1;
}
pid_t pid = fork();
if (pid == 0) {
char arg[4];
bzero( arg, 4 );
close(fd[1]);
sprintf( arg, "%d", fd[0] );
char* filename = "child";
ret = execl( filename, filename, arg, NULL );
Just for the sake of completeness, child program begins as follows:
int main(int argc, char *argv[] ) {
/* Create socket pair for communication with server, and fork/exec the server code */
if( argc < 2 ) {
perror("Usage: argv[0] <file descriptor>");
Any ideas? I get nothing, just the seg fault itself and I get it immediately.