From 0615c83bb22745df13e4c3dc1511b353290f3260 Mon Sep 17 00:00:00 2001 From: aquanight Date: Fri, 5 Dec 2008 21:01:31 +0000 Subject: [PATCH 1/1] 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 --- .inspircd.inc | 13 +++++++------ 1 file 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"; } } -- 2.39.5