aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2014-09-22 21:14:02 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2014-09-22 21:14:02 +0200
commitd6e7672545c717497490c0b0f54f64594f374f9d (patch)
tree736aa8a2f9264221709b45361939475c8ae83c24 /libbb
parent15943c886d6e1929b90db9bc6077c849cbaa187e (diff)
downloadbusybox-w32-d6e7672545c717497490c0b0f54f64594f374f9d.tar.gz
busybox-w32-d6e7672545c717497490c0b0f54f64594f374f9d.tar.bz2
busybox-w32-d6e7672545c717497490c0b0f54f64594f374f9d.zip
less: move "retry-on-EAGAIN" logic closer to read ops
This makes "G" (goto end of input) command work as well as /search_for_nonexistent_string: both will read to EOF now even from somewhat slow input (such as kernel's "git log"). function old new delta ndelay_on 35 43 +8 ndelay_off 35 43 +8 read_lines 695 691 -4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 16/-4) Total: 12 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r--libbb/xfuncs.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index 23f27516f..f25ce9446 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -25,20 +25,22 @@
25#include "libbb.h" 25#include "libbb.h"
26 26
27/* Turn on nonblocking I/O on a fd */ 27/* Turn on nonblocking I/O on a fd */
28void FAST_FUNC ndelay_on(int fd) 28int FAST_FUNC ndelay_on(int fd)
29{ 29{
30 int flags = fcntl(fd, F_GETFL); 30 int flags = fcntl(fd, F_GETFL);
31 if (flags & O_NONBLOCK) 31 if (flags & O_NONBLOCK)
32 return; 32 return flags;
33 fcntl(fd, F_SETFL, flags | O_NONBLOCK); 33 fcntl(fd, F_SETFL, flags | O_NONBLOCK);
34 return flags;
34} 35}
35 36
36void FAST_FUNC ndelay_off(int fd) 37int FAST_FUNC ndelay_off(int fd)
37{ 38{
38 int flags = fcntl(fd, F_GETFL); 39 int flags = fcntl(fd, F_GETFL);
39 if (!(flags & O_NONBLOCK)) 40 if (!(flags & O_NONBLOCK))
40 return; 41 return flags;
41 fcntl(fd, F_SETFL, flags & ~O_NONBLOCK); 42 fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
43 return flags;
42} 44}
43 45
44void FAST_FUNC close_on_exec_on(int fd) 46void FAST_FUNC close_on_exec_on(int fd)