From: Don Armstrong Date: Thu, 29 Mar 2018 20:45:23 +0000 (-0700) Subject: create directory for lockfiles if it doesn't exist X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=b544c3be9dfe2e98386ea988c07c176b2de6d18e;p=debbugs.git create directory for lockfiles if it doesn't exist --- diff --git a/Debbugs/Common.pm b/Debbugs/Common.pm index ae7d8b4..b0c6093 100644 --- a/Debbugs/Common.pm +++ b/Debbugs/Common.pm @@ -74,6 +74,8 @@ use Mail::Address; use Cwd qw(cwd); use Storable qw(dclone); use Time::HiRes qw(usleep); +use File::Path qw(mkpath); +use File::Basename qw(dirname); use Params::Validate qw(validate_with :types); @@ -792,6 +794,7 @@ sub lockpid { unlink $pidfile or die "Unable to unlink stale pidfile $pidfile $!"; } + mkpath(dirname($pidfile)); my $pidfh = IO::File->new($pidfile,O_CREAT|O_EXCL|O_WRONLY) or die "Unable to open $pidfile for writing: $!"; print {$pidfh} $$ or die "Unable to write to $pidfile $!";