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 | |
parent | b1bac0dab2e5ea99666fd95ef9f026273142446c (diff) | |
download | busybox-w32-ed270a5f32e4fee0d4b30595c888df54ac878fba.tar.gz busybox-w32-ed270a5f32e4fee0d4b30595c888df54ac878fba.tar.bz2 busybox-w32-ed270a5f32e4fee0d4b30595c888df54ac878fba.zip |
ash: make code simpler, and do not do close(-1) - it's rude
-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) | |||
3461 | * That sometimes helps to acquire controlling tty. | 3461 | * That sometimes helps to acquire controlling tty. |
3462 | * Obviously, a workaround for bugs when someone | 3462 | * Obviously, a workaround for bugs when someone |
3463 | * failed to provide a controlling tty to bash! :) */ | 3463 | * failed to provide a controlling tty to bash! :) */ |
3464 | fd += 3; | 3464 | fd = 2; |
3465 | while (!isatty(fd) && --fd >= 0) | 3465 | while (!isatty(fd)) |
3466 | ; | 3466 | if (--fd < 0) |
3467 | goto out; | ||
3467 | } | 3468 | } |
3468 | fd = fcntl(fd, F_DUPFD, 10); | 3469 | fd = fcntl(fd, F_DUPFD, 10); |
3469 | close(ofd); | 3470 | if (ofd >= 0) |
3471 | close(ofd); | ||
3470 | if (fd < 0) | 3472 | if (fd < 0) |
3471 | goto out; | 3473 | goto out; |
3474 | /* fd is a tty at this point */ | ||
3472 | close_on_exec_on(fd); | 3475 | close_on_exec_on(fd); |
3473 | do { /* while we are in the background */ | 3476 | do { /* while we are in the background */ |
3474 | pgrp = tcgetpgrp(fd); | 3477 | pgrp = tcgetpgrp(fd); |
@@ -3502,7 +3505,8 @@ setjobctl(int on) | |||
3502 | setsignal(SIGTTOU); | 3505 | setsignal(SIGTTOU); |
3503 | setsignal(SIGTTIN); | 3506 | setsignal(SIGTTIN); |
3504 | close: | 3507 | close: |
3505 | close(fd); | 3508 | if (fd >= 0) |
3509 | close(fd); | ||
3506 | fd = -1; | 3510 | fd = -1; |
3507 | } | 3511 | } |
3508 | ttyfd = fd; | 3512 | ttyfd = fd; |