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

Safe pipe open does not work properly under NT #357

Closed
p5pRT opened this issue Aug 9, 1999 · 3 comments

Comments

@p5pRT
Copy link
Collaborator

@p5pRT p5pRT commented Aug 9, 1999

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

Searchable as RT1191$

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Aug 9, 1999

From trajano@cyberdude.com

  # determine if the system can fork() properly
  eval 'fork || exit';
  my $can_fork = ($@​ eq '');

  my @​cmd = (ANYINFOEXEC, '-i', $in_format, $src);

  if ($can_fork) {
  open(S, '-|') || exec @​cmd || die $!;
  }
  else {
  local($ENV{PATH}) = ('');
  open(S, join(' ', @​cmd, '|')) || die $!;
  }

-----Original Message-----
From​: tkil@​jelerak.scrye.com [mailto​:tkil@​jelerak.scrye.com]On Behalf Of
Tkil
Sent​: Tuesday, May 18, 1999 1​:46 PM
To​: Archimedes Trajano
Cc​: perlbug@​perl.com
Subject​: Re​: Safe pipe open does not work properly under NT

Tom C is correct that you're not forking; the open is probably
returning "undef" (meaning "fork failed"), not "0" ("fork succeeded,
you're the child). this is covered in the perl for win32 FAQs. use a
more selective construct to determine the truth​:

my $pid = open T, "|-";
die "couldn't open child​: $!" unless defined $pid;

if ($pid == 0)
{
# child
exec "type";
}
else
{
# parent
$rc = wait;
}

or whatever.

also, note that Windows NT does not (so far as i know) have a command
called "cat". they use "type" to do trivial (one-file) operations, or
"copy" to actually concatenate files.

the error message sounds like it might have successfully forked, but
cannot find the "cat" command. either change it to "type" or make a
"cat.bat" file somewhere on your path.

t.
--
Tkil * <URL​: http​://www.scrye.com/~tkil> * hopelessly hopeless romantic.
"So amplify this little one | She hears as much as she can see
She's a volume freak | And what she sees, she
can't believe."
-- Catherine Wheel, _Happy Days_, "Judy Staring At The Sun"

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 28, 2004

From @steve-m-hay

Perl on Win32 does have a fork() emulation if it was built with threads
enabled (which the popular ActivePerl, for example, is), but even with
this fork() emulation, "piping opens" are still not supported -- see
perlport manpage.

Hence $can_fork is most likely a true value, but the open(S, '-|') will
still fail anyway. This is documented behaviour, not a bug.

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 28, 2004

@steve-m-hay - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.