aboutsummaryrefslogtreecommitdiff
path: root/shell/msh.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/msh.c
parentae86a338b89c1339588226cb2298e1785aaa7b90 (diff)
downloadbusybox-e376d454bb70ed41bbc3eb0358d37fa30c94358d.tar.gz
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/msh.c')
-rw-r--r--shell/msh.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/shell/msh.c b/shell/msh.c
index fd287f16e..917b08a1e 100644
--- a/shell/msh.c
+++ b/shell/msh.c
@@ -42,6 +42,7 @@
# define xmalloc(size) malloc(size)
# define msh_main(argc,argv) main(argc,argv)
# define safe_read(fd,buf,count) read(fd,buf,count)
+# define nonblock_safe_read(fd,buf,count) read(fd,buf,count)
# define NOT_LONE_DASH(s) ((s)[0] != '-' || (s)[1])
# define LONE_CHAR(s,c) ((s)[0] == (c) && !(s)[1])
# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
@@ -3376,7 +3377,7 @@ static int doread(struct op *t)
}
for (wp = t->words + 1; *wp; wp++) {
for (cp = global_env.linep; !nl && cp < elinep - 1; cp++) {
- nb = read(0, cp, sizeof(*cp));
+ nb = nonblock_safe_read(0, cp, sizeof(*cp));
if (nb != sizeof(*cp))
break;
nl = (*cp == '\n');
@@ -4799,7 +4800,7 @@ static int filechar(struct ioarg *ap)
if (i)
lseek(ap->afile, ap->afpos, SEEK_SET);
- i = safe_read(ap->afile, bp->buf, sizeof(bp->buf));
+ i = nonblock_safe_read(ap->afile, bp->buf, sizeof(bp->buf));
if (i <= 0) {
closef(ap->afile);
return 0;
@@ -4830,7 +4831,7 @@ static int filechar(struct ioarg *ap)
return c;
}
#endif
- i = safe_read(ap->afile, &c, sizeof(c));
+ i = nonblock_safe_read(ap->afile, &c, sizeof(c));
return i == sizeof(c) ? (c & 0x7f) : (closef(ap->afile), 0);
}
@@ -4841,7 +4842,7 @@ static int herechar(struct ioarg *ap)
{
char c;
- if (read(ap->afile, &c, sizeof(c)) != sizeof(c)) {
+ if (nonblock_safe_read(ap->afile, &c, sizeof(c)) != sizeof(c)) {
close(ap->afile);
c = '\0';
}