I seem to be having a problem running child processes in my
directfb(cvs)/gtk(2.0.5) program.  This might start to sound like a
pretty generic Linux/UNIX/gtk programming problem, but this program
works fine using the gtk library with X11 and with the generic
framebuffer.

In a gtk signal call back I try to spawn a child process.  I started
with using g_spawn_async_with_pipes() (which works fine using gtk with
X11 and generic frame buffer) but when the child process was failing
to start, I simplified the example with a simple fork()/exec() to see
what was going on.  Still, I was not getting the exec() happening so I
removed that and now have a very simple fork()/exit().

The problem is that that the child process never exits.  Here is the
meat of my my signal callback:


gchar **argv;

/* fill argv with a null terminated command line */

signal(SIGCHLD, child_reaper);
fprintf(stderr, "about to start child\n");
if (fork() == 0) {
    int i = 0;
    fprintf(stderr, "child starting:\n");
    while(argv[i])
        fprintf(stderr, "%s ", argv[i++]);
    fprintf(stderr, "\n");
//      execve(argv[0], argv, NULL);
    perror("execve");
    exit(1);
}
fprintf(stderr, "should be running child\n");


When I run my program and the callback is triggered, I get:

about to start child
should be running child
child starting:
child_process arg1 arg2 arg3
execve: Success

and then the child process hangs.  The exit(1) is never executed.
Here is some strace output of the child process creation and what it
does:

1108  rt_sigaction(SIGCHLD, {0x40548530, [CHLD], SA_RESTART|0x4000000}, {SIG_DFL}, 8) 
= 0
1108  write(2, "about to start child\n", 21) = 21
1108  fork()                            = 1125
1125  write(2, "child starting:\n", 16) = 16
1125  write(2, "child_process ", 14)   = 14
1125  write(2, "arg1 ", 5)              = 5
1125  write(2, "arg2 ", 5)              = 5
1125  write(2, "arg3 ", 5)              = 5
1125  write(2, "\n", 1)                 = 1
1125  write(2, "execve: Success\n", 16) = 16
1125  munmap(0x4180b000, 1921024)       = 0
1125  munmap(0x417b2000, 16384)         = 0
1125  munmap(0x4079d000, 16773120)      = 0
1125  ioctl(9, 0x4601, 0x805f290)       = 0
1113  <... read resumed> "000000000000e6ac 01 SPACE MY_REM"..., 128) = 108
1113  read(8,  <unfinished ...>
1108  --- SIGWINCH (Window changed) ---
1108  write(2, "should be running child\n", 24) = 24
...
1125  --- SIGWINCH (Window changed) ---
1125  ioctl(9, 0x4605, 0x805f330)       = 0
1125  close(9)                          = 0
1125  kill(1112, SIGRT_1)               = -1 ESRCH (No such process)
1125  rt_sigprocmask(SIG_SETMASK, NULL, [RTMIN], 8) = 0
1125  rt_sigsuspend([] <unfinished ...>
[ kill -9 signal sent to parent and all running children ]
1125  --- SIGHUP (Hangup) ---
...
1125  <... rt_sigsuspend resumed> )     = -1 EINTR (Interrupted system call)
1125  write(2, "(!) --->  CAUGHT SIGNAL 1  <---\n", 32) = 32
1125  rt_sigaction(SIGHUP, {SIG_DFL}, NULL, 8) = 0
1125  rt_sigaction(SIGINT, {SIG_DFL}, NULL, 8) = 0
1125  rt_sigaction(SIGTERM, {SIG_DFL}, NULL, 8) = 0
1125  rt_sigaction(SIGABRT, {SIG_DFL}, NULL, 8) = 0
1125  rt_sigaction(SIGFPE, {SIG_DFL}, NULL, 8) = 0
1125  rt_sigaction(SIGILL, {SIG_DFL}, NULL, 8) = 0
1125  rt_sigaction(SIGQUIT, {SIG_DFL}, NULL, 8) = 0
1125  rt_sigaction(SIGSEGV, {SIG_DFL}, NULL, 8) = 0
1125  rt_sigaction(SIGTRAP, {SIG_DFL}, NULL, 8) = 0
1125  rt_sigaction(SIGBUS, {SIG_DFL}, NULL, 8) = 0
1125  rt_sigaction(SIGXCPU, {SIG_DFL}, NULL, 8) = 0
1125  rt_sigaction(SIGXFSZ, {SIG_DFL}, NULL, 8) = 0
1125  kill(0, SIGHUP)                   = 0
1125  sigreturn()                       = ? (mask now [RTMIN])
1125  --- SIGHUP (Hangup) ---

and that's it.  As you can see, the exit(1) in the child process never
gets run.

Is there something I am missing about the execution environment of
DirectFB that is interfering with fork()/exec()?

Thanx,
b.

-- 
Brian J. Murrell

Attachment: msg00741/pgp00000.pgp
Description: PGP signature

Reply via email to