Re: Forking from Gtk - Problem solved!



On Wed, 9 Jul 2008 07:48:10 +0200
G Hasse <gorhas raditex se> wrote:

Yes - and it was a simple solution... The solution was:
Set a flag in the signal mask that we don't want to wait
for children and (make a dummy signal handler...)

//----------------------------------------------------------------------
// Just to ignore the signal
//----------------------------------------------------------------------
void MySigIgnore(int dummy)
{
   printf("I don't want to be zombie...\n");
}

//----------------------------------------------------------------------
// Main
//----------------------------------------------------------------------
main()
{

....

  struct sigaction act;

  act.sa_handler = MySigIgnore;
  sigemptyset(&act.sa_mask); /* non-standard */
  act.sa_flags = SA_NOCLDWAIT;
  
  sigaction(SIGCHLD, &act, NULL);

}
 
All SA_NOCLDWAIT does is avoid zombie entries in the process table - it
tells the OS that wait*() will not be called for the child
processes. Having a zombie process (a defunct entry in the process
table) shouldn't cause the issue you mention, so this "fix" would worry
me. In addition, you should not call printf() (or any other non
async-signal-safe function) in a signal handler.

If you want both to ignore the signal and avoid zombie processes, you
can in any event use SIG_IGN instead of a dummy signal handler: "If the
action for the SIGCHLD signal is set to SIG_IGN, child processes of the
calling processes shall not be transformed into zombie processes when
they terminate."

Chris




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