aboutsummaryrefslogtreecommitdiff
path: root/shell/ash.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-02-20 22:23:24 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-02-20 22:23:24 +0000
commite376d454bb70ed41bbc3eb0358d37fa30c94358d (patch)
treeeb53c600dcde841a7617a19f819ae3e9cfe7fd84 /shell/ash.c
parentae86a338b89c1339588226cb2298e1785aaa7b90 (diff)
downloadbusybox-w32-e376d454bb70ed41bbc3eb0358d37fa30c94358d.tar.gz
busybox-w32-e376d454bb70ed41bbc3eb0358d37fa30c94358d.tar.bz2
busybox-w32-e376d454bb70ed41bbc3eb0358d37fa30c94358d.zip
libbb: introduce and use nonblock_safe_read(). Yay!
Our shells are immune from this nasty O_NONBLOCK now! function old new delta nonblock_safe_read - 78 +78 file_get 276 295 +19 generateMTFValues 428 435 +7 read_line_input 1776 1772 -4 preadbuffer 543 450 -93 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/2 up/down: 104/-97) Total: 7 bytes text data bss dec hex filename 615190 715 23924 639829 9c355 busybox_old 615168 715 23924 639807 9c33f busybox_unstripped
Diffstat (limited to 'shell/ash.c')
-rw-r--r--shell/ash.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 65f94f682..debe8ecdd 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -5428,7 +5428,7 @@ expbackq(union node *cmd, int quoted, int quotes)
5428 read: 5428 read:
5429 if (in.fd < 0) 5429 if (in.fd < 0)
5430 break; 5430 break;
5431 i = safe_read(in.fd, buf, sizeof(buf)); 5431 i = nonblock_safe_read(in.fd, buf, sizeof(buf));
5432 TRACE(("expbackq: read returns %d\n", i)); 5432 TRACE(("expbackq: read returns %d\n", i));
5433 if (i <= 0) 5433 if (i <= 0)
5434 break; 5434 break;
@@ -8678,7 +8678,7 @@ preadfd(void)
8678 retry: 8678 retry:
8679#if ENABLE_FEATURE_EDITING 8679#if ENABLE_FEATURE_EDITING
8680 if (!iflag || parsefile->fd) 8680 if (!iflag || parsefile->fd)
8681 nr = safe_read(parsefile->fd, buf, BUFSIZ - 1); 8681 nr = nonblock_safe_read(parsefile->fd, buf, BUFSIZ - 1);
8682 else { 8682 else {
8683#if ENABLE_FEATURE_TAB_COMPLETION 8683#if ENABLE_FEATURE_TAB_COMPLETION
8684 line_input_state->path_lookup = pathval(); 8684 line_input_state->path_lookup = pathval();
@@ -8700,9 +8700,11 @@ preadfd(void)
8700 } 8700 }
8701 } 8701 }
8702#else 8702#else
8703 nr = safe_read(parsefile->fd, buf, BUFSIZ - 1); 8703 nr = nonblock_safe_read(parsefile->fd, buf, BUFSIZ - 1);
8704#endif 8704#endif
8705 8705
8706#if 0
8707/* nonblock_safe_read() handles this problem */
8706 if (nr < 0) { 8708 if (nr < 0) {
8707 if (parsefile->fd == 0 && errno == EWOULDBLOCK) { 8709 if (parsefile->fd == 0 && errno == EWOULDBLOCK) {
8708 int flags = fcntl(0, F_GETFL); 8710 int flags = fcntl(0, F_GETFL);
@@ -8715,6 +8717,7 @@ preadfd(void)
8715 } 8717 }
8716 } 8718 }
8717 } 8719 }
8720#endif
8718 return nr; 8721 return nr;
8719} 8722}
8720 8723
@@ -11801,7 +11804,7 @@ readcmd(int argc, char **argv)
11801 backslash = 0; 11804 backslash = 0;
11802 STARTSTACKSTR(p); 11805 STARTSTACKSTR(p);
11803 do { 11806 do {
11804 if (read(0, &c, 1) != 1) { 11807 if (nonblock_safe_read(0, &c, 1) != 1) {
11805 status = 1; 11808 status = 1;
11806 break; 11809 break;
11807 } 11810 }