in reply to Re^2: Have perl to start another perl script
in thread Have perl to start another perl script

system always returns 0 on successful launch. I recommend you do all the pid-saving in a wrapper shellscript (or Perlscript) around your child program:

#!/usr/bin/perl -w use strict; my $pid = $$; my ($IPaddress) = @ARGV; # Save our PID into the pidfile: my $pidfile = "/home/ember/devices/$Macaddress/$pid.pid"; open (FILE, "> $pidfile") or die "Can't create file $pidfile: $!\n"; print FILE "$pidfile\n"; close FILE; # and replace ourselves with the real program, which gets the same PID + as we had: exec 'other.pl', $IPaddress;

Replies are listed 'Best First'.
Re^4: Have perl to start another perl script
by hakana (Acolyte) on Jul 31, 2007 at 09:30 UTC
    The code worked fine but since it's a .cgi that starts the second script it's started as apache and after 120 sec the process is killed due to inactivity (send/reciv).

    Any one that has a solution to this?
  • Start as other user
  • remove timeout in httpd.conf?