I am writing a Perl script on Redhat Enterprise Linux 3. This script
is intended to be run at start-up, and as such I have modified one of
the scripts in /etc/init.d to start this script. This implies that the
Perl script "daemonizes" itself, that is, it does the usual:
$pid = fork ;
exit if $pid ;
use POSIX ;
POSIX::setsid() ;
I then do another fork so that the child of the parent can do some
work. In particular, this child makes a call to a Linux command of the
form
`/bin/grep string /var/spool/lpd/lpr1/filename`
It is at this line that the child dies. However, if I run the script
without invoking the /etc/init.d script, the child does not die. Thus,
there is something in the way the /etc/init.d script calls the perl
script that makes things go bad (perhaps the "daemon" function).
In all cases everything is running as root.
For a satisfactory answer I need to know how to fix the perl script so
that it does not die at the backtick commands. Note that at several
places I do different sorts of backtick commands, some of which cannot
be replaced by Perl code. |