diff options
author | Denys Vlasenko | 2009-11-11 21:05:42 +0100 |
---|---|---|
committer | Denys Vlasenko | 2009-11-11 21:05:42 +0100 |
commit | ab19ede65595f6c0daba1e9b6c7c0a2ede341fec (patch) | |
tree | 144f7f397a4c193e5af9b445d14fee7d471107d2 /coreutils/stty.c | |
parent | c096a6c2084b6d920182714beb842ebb40087182 (diff) | |
download | busybox-ab19ede65595f6c0daba1e9b6c7c0a2ede341fec.zip busybox-ab19ede65595f6c0daba1e9b6c7c0a2ede341fec.tar.gz |
tidy up O_NONBLOCK usage. use libbb functions in stty.
Added O_RDONLY where improves readability. Note: O_RDONLY == 0,
so it is there even if not specified.
function old new delta
stty_main 1289 1235 -54
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils/stty.c')
-rw-r--r-- | coreutils/stty.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/coreutils/stty.c b/coreutils/stty.c index cb9b183..f29fa64 100644 --- a/coreutils/stty.c +++ b/coreutils/stty.c @@ -1293,17 +1293,9 @@ int stty_main(int argc, char **argv) /* Now it is safe to start doing things */ if (file_name) { - int fd, fdflags; G.device_name = file_name; - fd = xopen_nonblocking(G.device_name); - if (fd != STDIN_FILENO) { - dup2(fd, STDIN_FILENO); - close(fd); - } - fdflags = fcntl(STDIN_FILENO, F_GETFL); - if (fdflags < 0 || - fcntl(STDIN_FILENO, F_SETFL, fdflags & ~O_NONBLOCK) < 0) - perror_on_device_and_die("%s: cannot reset non-blocking mode"); + xmove_fd(xopen_nonblocking(G.device_name), STDIN_FILENO); + ndelay_off(STDIN_FILENO); } /* Initialize to all zeroes so there is no risk memcmp will report a |