diff options
author | Nick Ing-Simmons <nik@tiuk.ti.com> | 2002-05-25 16:33:14 +0000 |
---|---|---|
committer | Nick Ing-Simmons <nik@tiuk.ti.com> | 2002-05-25 16:33:14 +0000 |
commit | f505b23a7a0989e1a97abda60cb97018925423d4 (patch) | |
tree | 085504d10905e70b9689f3e19c7059e9acd5c312 /perlio.c | |
parent | 0aa356c1277870a09fb0a72d88216267eefff4ac (diff) | |
parent | 7a069417d4f8915e3382ddb926c291967ba8fe1f (diff) | |
download | perl-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.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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); |