diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-26 05:37:07 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-26 05:37:07 +0000 |
commit | ed270a5f32e4fee0d4b30595c888df54ac878fba (patch) | |
tree | 27543eea4f0d2e17bf5270abbb579c81a0ed624e /shell | |
parent | b1bac0dab2e5ea99666fd95ef9f026273142446c (diff) | |
download | busybox-ed270a5f32e4fee0d4b30595c888df54ac878fba.tar.gz |
ash: make code simpler, and do not do close(-1) - it's rude
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/shell/ash.c b/shell/ash.c index 7f7531650..8f388f59b 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -3461,14 +3461,17 @@ setjobctl(int on) * That sometimes helps to acquire controlling tty. * Obviously, a workaround for bugs when someone * failed to provide a controlling tty to bash! :) */ - fd += 3; - while (!isatty(fd) && --fd >= 0) - ; + fd = 2; + while (!isatty(fd)) + if (--fd < 0) + goto out; } fd = fcntl(fd, F_DUPFD, 10); - close(ofd); + if (ofd >= 0) + close(ofd); if (fd < 0) goto out; + /* fd is a tty at this point */ close_on_exec_on(fd); do { /* while we are in the background */ pgrp = tcgetpgrp(fd); @@ -3502,7 +3505,8 @@ setjobctl(int on) setsignal(SIGTTOU); setsignal(SIGTTIN); close: - close(fd); + if (fd >= 0) + close(fd); fd = -1; } ttyfd = fd; |