summaryrefslogtreecommitdiff
path: root/perlio.c
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>2002-05-25 16:33:14 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>2002-05-25 16:33:14 +0000
commitf505b23a7a0989e1a97abda60cb97018925423d4 (patch)
tree085504d10905e70b9689f3e19c7059e9acd5c312 /perlio.c
parent0aa356c1277870a09fb0a72d88216267eefff4ac (diff)
parent7a069417d4f8915e3382ddb926c291967ba8fe1f (diff)
downloadperl-f505b23a7a0989e1a97abda60cb97018925423d4.tar.gz
Integrate mainline for Lupe's perlio.c fix before
starting on NetBSD issue p4raw-id: //depot/perlio@16783
Diffstat (limited to 'perlio.c')
-rw-r--r--perlio.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/perlio.c b/perlio.c
index 23864b56e9..b41b6d2735 100644
--- a/perlio.c
+++ b/perlio.c
@@ -2446,21 +2446,25 @@ PerlIO_importFILE(FILE *stdio, int fl)
/* We need to probe to see how we can open the stream
so start with read/write and then try write and read
we dup() so that we can fclose without loosing the fd.
+
+ Note that the errno value set by a failing fdopen
+ varies between stdio implementations.
*/
int fd = PerlLIO_dup(fileno(stdio));
char *mode = "r+";
FILE *f2 = fdopen(fd, mode);
PerlIOStdio *s;
- if (!f2 && errno == EINVAL) {
+ if (!f2) {
mode = "w";
f2 = fdopen(fd, mode);
}
- if (!f2 && errno == EINVAL) {
+ if (!f2) {
mode = "r";
f2 = fdopen(fd, mode);
}
if (!f2) {
/* Don't seem to be able to open */
+ PerlLIO_close(fd);
return f;
}
fclose(f2);