Google Answers Logo
View Question
 
Q: Perl backtick command causes daemon'ed script to die ( No Answer,   0 Comments )
Question  
Subject: Perl backtick command causes daemon'ed script to die
Category: Computers > Programming
Asked by: rlandfill-ga
List Price: $35.00
Posted: 04 Jul 2005 18:32 PDT
Expires: 04 Jul 2005 20:58 PDT
Question ID: 539958
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.

Request for Question Clarification by studboy-ga on 04 Jul 2005 19:15 PDT
Hi rlandfill-ga

Have you tried the system() approach?  ie

system("/bin/grep string /var/spool/lpd/lpr1/filename");

Thanks
studboy-ga

Clarification of Question by rlandfill-ga on 04 Jul 2005 20:13 PDT
I need the string returned by the command call. system() only returns an exit code.
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy