delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/02/27/16:37:33

From: "Tim Van Holder" <tim DOT van DOT holder AT pandora DOT be>
To: <djgpp-workers AT delorie DOT com>
Subject: FD 4 special for DJGPP (and Perl in particular)?
Date: Tue, 27 Feb 2001 22:37:31 +0100
Message-ID: <CAEGKOHJKAAFPKOCLHDIOEBJCBAA.tim.van.holder@pandora.be>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
Importance: Normal
Reply-To: djgpp-workers AT delorie DOT com

I'm running into a problem with autoupdate.
It is being rewritten in Perl, and invokes autoconf.
At some point, autoconf redirects file descriptor 4
to its output file, or fd 1 if outfile is "-".
However, the
  exec 4>&1
causes the following error:
redirection error: Bad file descriptor (EBADF)

Only fd 4 seems to be affected.

The error is easily reproduced; simply place the following
files in the same dir, and run the perl one:

--foo.pl--
open (FOO, "./foo.sh |");
while (<FOO>) { print $_; }
close FOO;

--foo.sh--
#! bash

exec 4>&1
echo foo >&4


There is no problem if foo.sh is run directly, from
another shell script or through system().
And although the error is printed, the exec does actually
seem to succeed ("foo" is output).

Can anyone reproduce this problem (I get it even if using
the perl from perl552b.zip, so it's not my perl 5.6.0 build
that's at fault)?
Is this a Perl thing or a DJGPP thing? I'm pretty certain it's
the former, as running foo.pl under the perl debugger kills the
console input (Perl probably closes fd 4).
Is there a fix / workaround?

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019