Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perl 5.063 error in open(.., "-|") #1074

Closed
p5pRT opened this issue Jan 24, 2000 · 5 comments
Closed

perl 5.063 error in open(.., "-|") #1074

p5pRT opened this issue Jan 24, 2000 · 5 comments

Comments

@p5pRT
Copy link

p5pRT commented Jan 24, 2000

Migrated from rt.perl.org#2027 (status was 'resolved')

Searchable as RT2027$

@p5pRT
Copy link
Author

p5pRT commented Jan 24, 2000

From ton@aucs-europe.net

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.

Perl Info



@p5pRT
Copy link
Author

p5pRT commented Jan 24, 2000

From @gsar

On 24 Jan 2000 17​:58​:15 GMT, ton@​aucs-europe.net wrote​:

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 STDER
R "child $$\n"; exec("ls"); };}'

will hang on the second fork.

Yeah, you want change#4757 which got sent here.

Sarathy
gsar@​ActiveState.com

@p5pRT
Copy link
Author

p5pRT commented Jan 24, 2000

From [Unknown Contact. See original ticket]

Hi,

Gurusamy Sarathy​:

Yeah, you want change#4757 which got sent here.

All those partial changes make following the list somewhat difficult.

Could somebody please set up some sort of anonymous CVS?

--
Matthias Urlichs | noris network GmbH | smurf@​noris.de | ICQ​: 20193661
The quote was selected randomly. Really. | http​://www.noris.de/~smurf/
--
I am bidden to surrender myself to the Lord of the Worlds. He is it who
created you of the dust...
  -- The Koran, Sura 40

@p5pRT
Copy link
Author

p5pRT commented Jan 24, 2000

From @gsar

On Mon, 24 Jan 2000 19​:43​:46 +0100, "Matthias Urlichs" wrote​:

Gurusamy Sarathy​:

Yeah, you want change#4757 which got sent here.

All those partial changes make following the list somewhat difficult.

Could somebody please set up some sort of anonymous CVS?

There was a p42cvs bridge under construction last I heard. Be sure
to talk to Barrie Slaymaker <barrie@​slaysys.com> to contribute towards
the effort.

Meanwhile, bookmark this, and visit when you feel the urge​:

  ftp​://ftp.linux.activestate.com/pub/staff/gsar/APC/

Sarathy
gsar@​ActiveState.com

@p5pRT
Copy link
Author

p5pRT commented Jan 24, 2000

From [Unknown Contact. See original ticket]

Hi,

Gurusamy Sarathy​:

ftp&#8203;://ftp\.linux\.activestate\.com/pub/staff/gsar/APC/

OK, the diffs/ subdir there is enough to let me auto-checkin the beast
into my local PRCS tree. Thanks.

--
Matthias Urlichs | noris network GmbH | smurf@​noris.de | ICQ​: 20193661
The quote was selected randomly. Really. | http​://www.noris.de/~smurf/
--
Just because your doctor has a name
for your condition doesn't mean he knows what it is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant