Commit 8a23b5e2 authored by Leigh B Stoller's avatar Leigh B Stoller

Make sure that we send email from the parent process, not child.

parent e02a3e7d
#!/usr/bin/perl -w #!/usr/bin/perl -w
# #
# Copyright (c) 2000-2014 University of Utah and the Flux Group. # Copyright (c) 2000-2015 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -77,6 +77,9 @@ my $savelog = 0; ...@@ -77,6 +77,9 @@ my $savelog = 0;
# on errors # on errors
my $fancy = 0; my $fancy = 0;
# We be forked.
my $forked = 0;
# Extra info used when AUDIT_FANCY is set # Extra info used when AUDIT_FANCY is set
my %AUDIT_INFO; my %AUDIT_INFO;
...@@ -377,6 +380,10 @@ sub AuditFork() ...@@ -377,6 +380,10 @@ sub AuditFork()
# Create a new session to ensure we are clear of any process group. # Create a new session to ensure we are clear of any process group.
# #
POSIX::setsid(); POSIX::setsid();
# For exit handling.
$SAVEPID = $PID;
$forked = 1;
return 0; return 0;
} }
...@@ -626,6 +633,9 @@ sub AddAuditInfo ($$) { ...@@ -626,6 +633,9 @@ sub AddAuditInfo ($$) {
# When the script ends, if the audit has not been sent, send it. # When the script ends, if the audit has not been sent, send it.
# #
END { END {
return
if ($forked && $PID != $SAVEPID);
# Save, since shell commands will alter it. # Save, since shell commands will alter it.
my $exitstatus = $?; my $exitstatus = $?;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment