Skip to content
Open
11 changes: 8 additions & 3 deletions bin/pgaudit_analyze
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ use lib dirname($0) . '/../lib';
use PgAudit::CSV;
use PgAudit::Wait;

# Flush the output buffer. $| is named $OUTPUT_AUTOFLUSH in English.pm.
$|++;
Comment thread
amalek215 marked this conversation as resolved.

####################################################################################################################################
# Usage
####################################################################################################################################
Expand Down Expand Up @@ -597,11 +600,9 @@ sub daemonInit
chdir '/'
or confess "chdir() failed: $!";

# Close stdin/stdout/stderr
# Close stdin and stderr. 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: $!";
open STDERR, '<', '/dev/null'
or confess "Couldn't close standard error: $!";

Expand Down Expand Up @@ -646,6 +647,10 @@ my $strNextLogFile = nextLogFile($strLogPath);
open(my $hLog, '>>', $strLogOutFile)
or confess "unable to open pgAudit Analyze log file $strLogOutFile: $!";

# Redirect stdout to log file
open(STDOUT, '>&', $hLog)
or confess "unable to close standard output and redirect to log file: $!";

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