RE: SUMMARY: Process goes down

From: Lebar, Russell J <Russell.J.LeBar_at_erac.com>
Date: Tue Jun 07 2005 - 14:05:33 EDT
> -----Original Message-----
> From: sunmanagers-bounces@sunmanagers.org >
> Russel send me a perl script that should do the trick but i
> didn't try it yet.

Looks like some of the formatting was lost. Here is the
script with comments following it. FYI, this is slightly
modified code from a script used in production.

#!/usr/bin/perl
use IO::Socket;
use POSIX qw(WNOHANG setsid);
$SIG{CHLD} = 'IGNORE';
die "Can't fork" unless defined ( my $child = fork );
CORE::exit(0) if $child;
setsid();
open( STDIN,  "</dev/null" );
open( STDOUT, ">/dev/null" );
open( STDERR, ">&STDOUT"   );
chdir '/tmp';
umask(0);
$ENV{PATH} = '/bin:/sbin:/usr/sbin';
exec "your command here";
=pod
01: shebang
02: use a module
03: use a module
04: Configure to autoreap zombies
05: fork
06: Parent exits
07: Become session leader
08: Detach STDIN from shell
09: Detach STDOUT from shell
10: Detach STDERR from shell
11: Change working directory
12: Reset umask
13: Reset PATH
14: Execute you command
=cut

-- Russ
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Wed Jun 8 09:26:24 2005

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:47 EST