Skip to content
Open
11 changes: 7 additions & 4 deletions bin/pgaudit_analyze
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ use POSIX qw(setsid);
use lib dirname($0) . '/../lib';
use PgAudit::CSV;
use PgAudit::Wait;

# flush the output buffer
$|++;
Comment thread
amalek215 marked this conversation as resolved.
####################################################################################################################################
# Usage
####################################################################################################################################
Expand Down Expand Up @@ -596,11 +597,9 @@ sub daemonInit
chdir '/'
or confess "chdir() failed: $!";

# close stdin/stdout
# close stdin, stdout previously closed/redirected
open STDIN, '<', '/dev/null'
or confess "Couldn't close standard input: $!";
open STDOUT, '>', $strLogOutFile
or confess "Couldn't close standard output: $!";

# create new process
defined($pid = fork)
Expand Down Expand Up @@ -634,6 +633,10 @@ my $strNextLogFile = nextLogFile($strLogPath);
open(my $hLog, '>', $strLogOutFile)
or confess "unable to open pgAudit Analyze log file $strLogOutFile: $!";

# Always redirect stdout to logfile
open (STDOUT, '>&', $hLog)
or confess "Couldn't close standard output and redirect to logfile: $!";

# Daemonize the process
daemonInit()
if ($bDaemon);
Expand Down