[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
[ID 20000124.003] perl 5.063 error in open(.., "-|")
This is a bug report for perl from hostmaster@att-unisource.net,
generated with the help of perlbug 1.26 running under perl 5.00503.
-----------------------------------------------------------------
[Please enter your report here]
perl -we 'for (1..2) { defined($pid = open(FILE, "-|")) || die "Could not fork: $!"; if ($pid) { print STDERR "parent $$\n"; while (<FILE>) {}; close FILE; } else { print STDERR "child $$\n"; exec("ls"); };}'
will hang on the second fork.
This is bug was introduced by the changes in open to support 3 arg open.
Relevant code in Perl_do_open9 in doio.c:
bool
Perl_do_open9(pTHX_ GV *gv, register char *name, I32 len, int as_raw,
int rawmode, int rawperm, PerlIO *supplied_fp, SV *svs,
I32 num_svs)
{
...
char *myname;
char *type = name;
...
myname = savepvn(name, len);
SAVEFREEPV(myname);
name = myname;
...
type[--tlen] = '\0';
while (tlen && isSPACE(type[tlen-1]))
type[--tlen] = '\0';
Notice how the arg 'name' is saved, but the modification
through 'type' changes the OLD version. This causes the given program
to call open(FILE, "-|") the first time, and open(FILE, "-") the
second time.
This modification through type happens several times in open9, so
it will be possible to construct many other cases.
[Please do not change anything below this line]
-----------------------------------------------------------------
---
- Follow-Ups from:
-
Gurusamy Sarathy <gsar@ActiveState.com>
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]