[Orca-checkins] r524 - orca/trunk/data_gatherers/procallator
blair at orcaware.com
blair at orcaware.com
Wed Feb 1 21:21:22 PST 2006
Author: blair at orcaware.com
Date: Wed Feb 1 21:20:54 2006
New Revision: 524
Modified:
orca/trunk/data_gatherers/procallator/procallator.pl.in
Log:
Have procallator do a better job of daemonizing itself. Hopefully,
this will enable an 'ssh hostname procallator' to start and close the
ssh connection immediately.
* data_gatherers/procallator/procallator.pl.in:
If $DEBUG is not true, then chdir() into / and re-open() STDIN on
/dev/null.
Modified: orca/trunk/data_gatherers/procallator/procallator.pl.in
==============================================================================
--- orca/trunk/data_gatherers/procallator/procallator.pl.in (original)
+++ orca/trunk/data_gatherers/procallator/procallator.pl.in Wed Feb 1 21:20:54 2006
@@ -138,11 +138,20 @@
my (@nfs_s_p3_fsinfo, @nfs_s_p3_pathconf);
my (@nfs_s_p3_commit, @nfs_s_p4_compound);
+# If procallator should daemonize itself, then do so now.
if ( !$DEBUG ) {
- use POSIX qw(setsid);
- umask 0;
- exit(0) if (fork);
- setsid;
+ my $expr = 'use POSIX qw(setsid)';
+ local $SIG{__DIE__} = 'DEFAULT';
+ local $SIG{__WARN__} = \&die_when_called;
+ eval $expr;
+ if ($@) {
+ die "$0: cannot get POSIX::setsid since eval '$expr' failed: $@\n";
+ }
+ chdir('/') or die "$0: cannot chdir '/': $!\n";
+ open(STDIN, '/dev/null') or die "$0: cannot open '/dev/null': $!\n";
+ defined(my $pid = fork) or die "$0: cannot fork: $!\n";
+ exit(0) if $pid;
+ POSIX::setsid() or die "$0: cannot start a new session: $!\n";
}
# Create output dir if needed
More information about the Orca-checkins
mailing list