Re: Forking from Gtk - Problem solved!





On Tue, Jul 08, 2008 at 08:59:45PM -0400, James Scott Jr wrote:

On Tue, 2008-07-08 at 23:23 +0200, G Hasse wrote:
On Tue, Jul 08, 2008 at 01:52:00PM -0400, James Scott Jr wrote:
G,

I've seen most of the other responses, and better understand what you
are trying to do.  And like others -- fork() is not recommended. 

Now I can recommend it! (If it fits your need).
 
I can't belive this... Certanly a forground process must be able to
start a process that completly detatch from the parent. Gtk or not
it could not matter. If I fork a Gtk program I migt have a lot of
GtkWidget pointers that are of no use - but if I bother I should be
able to free those. The gtk_main loop runs around to find out if
signals have been emitted. So if I exit this loop no sutch activity
should be going on.

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);

}

So now my program works as I want it to. And there is no
problem to fork from a foreground process, let the
child do its job and then die in peace.

Tanks all for your help!

-- 
Göran Hasse

----------------------------------------------------------------
Göran Hasse           email: gorhas raditex se  Tel: 019-450105
Raditex AB             http://www.raditex.se    
Planiavägen 15, 1tr                             Mob: 070-5530148
131 34  NACKA, SWEDEN                         OrgNr: 556240-0589
VAT: SE556240058901
------------------------------------------------------------------




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