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

> Stas,
> 
> I had the following in my code:
> 
>       my($nOrgPID) = fork;
>       exit if $nOrgPID;
>       die "Could not fork: $!" unless defined $nOrgPID;
> 
>       close STDIN;
>       close STDOUT;
>       close STDERR;
>       setsid() or die "Could not start new session: $!";
> 
> 
> but that didn't work, however when I changed it to this:
> 
>       my($nOrgPID) = fork;
>       exit if $nOrgPID;
>       die "Could not fork: $!" unless defined $nOrgPID;
> 
>       require 'sys/syscall.ph';
>       for (my $i=0; $i<=255; $i++) {
>          syscall(&SYS_close, $i + 0);  # must force numeric
>       }
> 
>       setsid() or die "Could not start new session: $!";
> 
> 
> the socket got released and I could restart the server. I 
> know it is a little crud, but it seems to work.

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?

_____________________________________________________________________
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