develooper Front page | perl.perl5.porters | Postings from December 2008

[perl #54422] man perlipc problem - setsid

From:
Steve Peters via RT
Date:
December 2, 2008 05:59
Subject:
[perl #54422] man perlipc problem - setsid
Message ID:
rt-3.6.HEAD-10965-1228194677-1357.54422-15-0@perl.org
On Sun May 18 21:20:58 2008, andrew@sundale.net wrote:
> 
> This is a bug report for perl from andrew@sundale.net,
> generated with the help of perlbug 1.35 running under perl v5.8.5.
> 
> 
> -----------------------------------------------------------------
> [Please enter your report here]
> 
> man perlipc gives in paragraph "Complete Dissociation of Child from
>    Parent"
> the following example:
> "use POSIX 'setsid';
> 
>     sub daemonize {
>         chdir '/'               or die "Can't chdir to /: $!";
>         open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
>         open STDOUT, '>/dev/null'
>                                 or die "Can't write to /dev/null: $!";
>         defined(my $pid = fork) or die "Can't fork: $!";
>         exit if $pid;
>         setsid                  or die "Can't start a new session:
>    $!";
> "
> 
> The line with "setsid" call will never die, because according to
>    POSIX.xs:
> "pid_t
> setsid()"
> it simply returns the result of setsid() call.
> According to "man 2 setsid" the call returns -1 on error, so the
>    script will never
> die on this line.
> The same is true for many other POSIX functions, like for example:
> "pid_t
> tcgetpgrp(fd)
>         int             fd
> "
> 

This documentation problem has been fixed with change #34976.

Steve Peters



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About