diff options
| author | christos <christos@NetBSD.org> | 2000-11-29 15:30:20 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2000-11-29 15:30:20 +0000 |
| commit | 2a213d0e9ac5f8e9fd97130ca7d4e1cdb7eeee23 (patch) | |
| tree | 23fb3dc759f717742b2dd83cb93bffb87df95710 /lib/libc/stdio | |
| parent | e8048693f83fbe5ae5c5287f01ad8b21cdf63c56 (diff) | |
make sure we preserve errno.
Diffstat (limited to 'lib/libc/stdio')
| -rw-r--r-- | lib/libc/stdio/fopen.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/libc/stdio/fopen.c b/lib/libc/stdio/fopen.c index cd8c993a1b9..f859fd6f036 100644 --- a/lib/libc/stdio/fopen.c +++ b/lib/libc/stdio/fopen.c @@ -1,4 +1,4 @@ -/* $NetBSD: fopen.c,v 1.9 2000/01/15 01:11:45 christos Exp $ */ +/* $NetBSD: fopen.c,v 1.10 2000/11/29 15:30:20 christos Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)fopen.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: fopen.c,v 1.9 2000/01/15 01:11:45 christos Exp $"); +__RCSID("$NetBSD: fopen.c,v 1.10 2000/11/29 15:30:20 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -73,12 +73,14 @@ fopen(file, mode) if (oflags & O_NONBLOCK) { struct stat st; if (fstat(f, &st) == -1) { - close(f); + int sverrno = errno; + (void)close(f); + errno = sverrno; goto release; } if (!S_ISREG(st.st_mode)) { + (void)close(f); errno = EFTYPE; - close(f); goto release; } } |
