David Thompson:
 |>  -->  |   \--- 840925 <defunct>
 |
 |If I wait on the child, then wouldn't the user have to exit the 
 |browser to return, thus locking up the dxui while you're using help? 
 |This is what I was trying to get away from by using fork.

I see.  However, fork doesn't get around it.  Until the parent waits on
terminated children, a defunct process sticks around.

 |I guess you've dealt with this more than I. The code is pretty small 
 |for the changes that need to be made so let's hash this out.
 |
 |If I strip out the code that was doing all the pid checking, etc. 
 |then just go with the solution of system( "%s \"$url\" &", browser ) 
 |and offer a script such as your url_handler, that should suffice. 
 |However, I found that with the system() call, if somebody sets this 
 |to call netscape, the dxui locks up until the process is finished. 

system is actually equivalent to fork() -> in child: exec() 
                                        -> in parent: wait()

With the above syntax, you actually are invoking a shell (/bin/sh likely)
to do the execing/backgrounding of the browser process.  It's blocking
until the browser terminates, which blocks the parent because it's waiting
on the child.

 |That is why I was using the fork and basically leaving defunct 
 |process lying around until the dxui quit. Does anybody have 
 |suggestions on how to handle this any other way?

IIRC "UNIX Network Programming" by Stevens (among others) has some code to
handle this with an explanation into what each fragment does, described
under starting daemon processes.  Vaguely I recall double fork, close all
your open file descriptors, and sometimes become a process group leader,
and separate yourself from the controlling terminal.

This is probably in several FAQs somewhere too.  I'd browser a bit more but
I have an appt to catch.  I'd search www.faqs.org or groups.google.com for
"double fork", or grab Stevens if you have it handy.

Randy

-- 
Randall Hopper (mailto:[EMAIL PROTECTED])
Lockheed Martin Operation Support
EPA Scientific Visualization Center
US EPA N127-01; RTP, NC 27711

Reply via email to