Re: gtk in fork()ed process



Marcelo wrote:

Well, if you don't at least wait4() the child process, you will let zombie process stay on your system 
until the main program dies, when init becomes parent of the zombies and clean them for you.
So, if you have to clean the process, you can do the error check by the return value of the child. Look:

pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage)

you can just call wait4 this way:
  int ret;
  wait4 (child_pid, &ret, 0, NULL);
and them, to check the return value,
  if (!WIFEXITED (ret) || WEXITSTATUS(ret)) {
    gtk....show_dialog..iguessthisisimplementedin2.0 ("Child process failed.");
  }

The parent process must not be stopped when the child process is running.
I now added an inter process comunication via pipe to display the error meassge
by the parent process.

I think the cleanup of the zombie can be done in the parent process by a signal
handler (sigaction(SIGCHLD)).

Bye
Oliver

-- 
Homepage:       http://www.rauch-domain.de
sane-umax:      http://www.rauch-domain.de/sane-umax
xsane:          http://www.xsane.org
E-Mail:         mailto:Oliver Rauch rauch-domain de



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]