On Fri, 15 Dec 2000, Kees Vonk 7249 24549 wrote:

> > But you don't need to call setsid() when you fork. Why
> > looking for complicated workaround when you can do it
> > properly without any workaround. Have you ever seen an
> > example of fork that uses setsid?
> 
> Ok,
> 
> here is my confusion: I call the the long running process 
> from the modperl script with a system() call that was why I 
> was using the setsid() (in the longrunning process).
> 
> I have now changed the code my long running process to:
> 
>    my($nOrgPID) = fork;
>    exit if $nOrgPID;
>    die "Could not fork: $!" unless defined $nOrgPID;
> 
>    close STDIN;
>    close STDOUT;
>    close STDERR;
> 
> 
> and that does not work, I have also tried putting it in the 
> modperl script instead but that doesn't work either.

Kees, if you are doing system() call just put setsid back, and add this:

 tie *OUT, 'Apache';
 close OUT;

Apache keeps the socket tied. Tell me whether this works for you.

I'll document these things shortly and post for your review.


> 
> What am I doing wrong and why would the setsid() be a 
> showstopper, especially as it is called after the close 
> statements (it doesn't reopen the filehandles does it).
> I could understand that it would possibly be unnecessary, but 
> how could it stop this code from working?
> 
> Another (more detailed) run through.
> 
>  1. modperl script starts long running process (lrp) with a 
>     system() call.
>  2. lrp runs the code above (fork + close (tried this with 
>     and without setsid)).
>  3. stop apache
>  4. start apache - fails (port in use)
>  5. netstat -na reveals port in LISTEN state.
>  6. kill lrp
>  7. netstat -na reveals port no longer in use.
>  8. start apache - now starts fine
> 
> 
> I think I am doing something wrong somewhere, but I am not 
> sure where. Is it right that I have to do the system call and 
> the fork?
> 
> Kees
> 
> 
> 



_____________________________________________________________________
Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
http://stason.org/       mod_perl Guide  http://perl.apache.org/guide 
mailto:[EMAIL PROTECTED]   http://apachetoday.com http://logilune.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/  


Reply via email to