Diff of /trunk/mkinitrd-magellan/busybox/libbb/fclose_nonstdin.c
Parent Directory | Revision Log | Patch
revision 815 by niro, Sat Sep 1 22:45:15 2007 UTC | revision 816 by niro, Fri Apr 24 18:33:46 2009 UTC | |
---|---|---|
# | Line 14 | Line 14 |
14 | ||
15 | #include "libbb.h" | #include "libbb.h" |
16 | ||
17 | int fclose_if_not_stdin(FILE *f) | int FAST_FUNC fclose_if_not_stdin(FILE *f) |
18 | { | { |
19 | if (f != stdin) { | /* Some more paranoid applets want ferror() check too */ |
20 | return fclose(f); | int r = ferror(f); /* NB: does NOT set errno! */ |
21 | } | if (r) errno = EIO; /* so we'll help it */ |
22 | return 0; | if (f != stdin) |
23 | return (r | fclose(f)); /* fclose does set errno on error */ | |
24 | return r; | |
25 | } | } |
|