summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko2013-11-28 03:14:16 +0100
committerDenys Vlasenko2013-11-28 03:14:16 +0100
commit259b3c047aea430c4aaecbdb9580a07e67691e8d (patch)
tree937c646d6384e0f79c11ef3d6527601ce164911b /libbb
parent8bd810bd276d20451faafdae88df4af9c2dd96d1 (diff)
downloadbusybox-259b3c047aea430c4aaecbdb9580a07e67691e8d.zip
busybox-259b3c047aea430c4aaecbdb9580a07e67691e8d.tar.gz
sed: open input files sequentially to avoid EMFILE
Currently, sed pre-opens all files, which may cause EMFILE errors on systems with low ulimit -n. Change sed to open one file at a time. function old new delta get_next_line 177 235 +58 sed_main 682 652 -30 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 58/-30) Total: 28 bytes Based on the patch by Daniel Borca <dborca@yahoo.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r--libbb/fclose_nonstdin.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libbb/fclose_nonstdin.c b/libbb/fclose_nonstdin.c
index 5ce9d5b..1b14413 100644
--- a/libbb/fclose_nonstdin.c
+++ b/libbb/fclose_nonstdin.c
@@ -18,7 +18,8 @@ int FAST_FUNC fclose_if_not_stdin(FILE *f)
{
/* Some more paranoid applets want ferror() check too */
int r = ferror(f); /* NB: does NOT set errno! */
- if (r) errno = EIO; /* so we'll help it */
+ if (r)
+ errno = EIO; /* so we'll help it */
if (f != stdin)
return (r | fclose(f)); /* fclose does set errno on error */
return r;