mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-12-23 05:07:54 +00:00
Fixed with test: Test bug #35820: sem breaks if $HOME is not writable
This commit is contained in:
parent
aad8d689ba
commit
1371108e64
23
src/parallel
23
src/parallel
|
@ -5000,9 +5000,9 @@ sub new {
|
|||
$id=~s/([^-_a-z0-9])/unpack("H*",$1)/ige; # Convert non-word chars to hex
|
||||
$id="id-".$id; # To distinguish it from a process id
|
||||
my $parallel_dir = $ENV{'HOME'}."/.parallel";
|
||||
-d $parallel_dir or mkdir $parallel_dir;
|
||||
-d $parallel_dir or mkdir_or_die($parallel_dir);
|
||||
my $parallel_locks = $parallel_dir."/semaphores";
|
||||
-d $parallel_locks or mkdir $parallel_locks;
|
||||
-d $parallel_locks or mkdir_or_die($parallel_locks);
|
||||
my $lockdir = "$parallel_locks/$id";
|
||||
my $lockfile = $lockdir.".lock";
|
||||
if($count < 1) { ::die_bug("semaphore-count: $count"); }
|
||||
|
@ -5082,7 +5082,7 @@ sub atomic_link_if_count_less_than {
|
|||
$self->lock();
|
||||
::debug($self->nlinks()."<".$self->{'count'});
|
||||
if($self->nlinks() < $self->{'count'}) {
|
||||
-d $self->{'lockdir'} || mkdir $self->{'lockdir'};
|
||||
-d $self->{'lockdir'} or mkdir_or_die($self->{'lockdir'});
|
||||
if(not -e $self->{'idfile'}) {
|
||||
open (A, ">", $self->{'idfile'}) or
|
||||
::die_bug("write_idfile: $self->{'idfile'}");
|
||||
|
@ -5137,6 +5137,23 @@ sub unlock {
|
|||
::debug("unlocked\n");
|
||||
}
|
||||
|
||||
sub mkdir_or_die {
|
||||
# If dir is not writable: die
|
||||
my $dir = shift;
|
||||
my @dir_parts = split(m:/:,$dir);
|
||||
my ($ddir,$part);
|
||||
while(defined ($part = shift @dir_parts)) {
|
||||
$part eq "" and next;
|
||||
$ddir .= "/".$part;
|
||||
-d $ddir and next;
|
||||
mkdir $ddir;
|
||||
}
|
||||
if(not -w $dir) {
|
||||
print STDERR "$Global::progname: Cannot write to $dir: $!\n";
|
||||
exit(255);
|
||||
}
|
||||
}
|
||||
|
||||
# Keep perl -w happy
|
||||
$::opt_x = $Semaphore::timeout = $Semaphore::wait = $::opt_shebang =
|
||||
0;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo '### Test fix #32191'
|
||||
seq 1 150 | parallel -j9 --retries 2 -S localhost,: "/bin/non-existant 2>/dev/null"
|
||||
seq 1 150 | nice nice parallel -j9 --retries 2 -S localhost,: "/bin/non-existant 2>/dev/null"
|
||||
|
||||
echo '### Test --tagstring'
|
||||
parallel -j1 -X -v --tagstring a{}b echo ::: 3 4
|
||||
|
@ -9,3 +9,9 @@ parallel -j1 -k -v --tagstring a{}b echo ::: 3 4
|
|||
parallel -j1 -k -v --tagstring a{}b echo job{#} ::: 3 4
|
||||
parallel -j1 -k -v --tagstring ajob{#}b echo job{#} ::: 3 4
|
||||
|
||||
echo '### Test bug #35820: sem breaks if $HOME is not writable'
|
||||
echo 'Workaround: use another writable dir'
|
||||
rm -rf /tmp/.parallel
|
||||
HOME=/tmp sem echo OK
|
||||
HOME=/tmp sem --wait
|
||||
HOME=/usr/this/should/fail stdout sem echo should fail
|
||||
|
|
|
@ -14,3 +14,7 @@ echo job1
|
|||
ajob1b job1
|
||||
echo job2
|
||||
ajob2b job2
|
||||
### Test bug #35820: sem breaks if $HOME is not writable
|
||||
Workaround: use another writable dir
|
||||
OK
|
||||
parallel: Cannot write to /usr/this/should/fail/.parallel: No such file or directory
|
||||
|
|
Loading…
Reference in a new issue