diff options
author | aquanight <aquanight@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-12-05 21:01:31 +0000 |
---|---|---|
committer | aquanight <aquanight@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-12-05 21:01:31 +0000 |
commit | 0615c83bb22745df13e4c3dc1511b353290f3260 (patch) | |
tree | b7b0d301df6838622308d3e4ff40dfddc12fe5a5 | |
parent | cde4352b02cf82c2df2232d9fb5c27ae9e5f6ba3 (diff) |
Make valdebug-unattended create the logging directory if necessary, and use sysopen with mode to open the logfiles rather than umasking.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10846 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | .inspircd.inc | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/.inspircd.inc b/.inspircd.inc index 6f8a12606..33626b1f3 100644 --- a/.inspircd.inc +++ b/.inspircd.inc @@ -180,13 +180,14 @@ sub valdebugunattended my $pid = fork; if ($pid == 0) { POSIX::setsid(); - umask 022; - open STDERR, '>', "$valgrindlogpath/valdebug.$$" or die $!; - umask 066; - open STDIN, '/dev/null' or die $!; - open STDOUT, '>', "$valgrindlogpath/out.$$" or die $!; + use Fcntl; + -d $valgrindlogpath or mkdir $valgrindlogpath or die "Cannot create $valgrindlogpath: $!\n"; + my $suffix = strftime("%Y%m%d-%H%M%S", localtime(time)) . ".$$"; + open STDIN, '<', '/dev/null' or die "Can't redirect STDIN to /dev/null: $!\n"; + sysopen STDOUT, "$valgrindlogpath/out.$suffix", O_WRONLY | O_CREAT | O_NOCTTY | O_APPEND, 0600 or die "Can't open $valgrindlogpath/out.$suffix: $!\n"; + sysopen STDERR, "$valgrindlogpath/valdebug.$suffix", O_WRONLY | O_CREAT | O_NOCTTY | O_APPEND, 0666 or die "Can't open $valgrindlogpath/valdebug.$suffix: $!\n"; exec "valgrind -v --tool=memcheck --leak-check=yes --num-callers=10 --time-stamp=yes --log-fd=2 $binpath/$executable -nofork -debug -nolog"; - exit 1; + die "Can't execute valgrind: $!\n"; } } |