diff options
Diffstat (limited to 'util-linux/script.c')
| -rw-r--r-- | util-linux/script.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/util-linux/script.c b/util-linux/script.c index abcd73bff..86475c1f1 100644 --- a/util-linux/script.c +++ b/util-linux/script.c | |||
| @@ -23,6 +23,7 @@ | |||
| 23 | //usage: ) | 23 | //usage: ) |
| 24 | 24 | ||
| 25 | #include "libbb.h" | 25 | #include "libbb.h" |
| 26 | #include "common_bufsiz.h" | ||
| 26 | 27 | ||
| 27 | int script_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 28 | int script_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
| 28 | int script_main(int argc UNUSED_PARAM, char **argv) | 29 | int script_main(int argc UNUSED_PARAM, char **argv) |
| @@ -108,11 +109,12 @@ int script_main(int argc UNUSED_PARAM, char **argv) | |||
| 108 | 109 | ||
| 109 | if (child_pid) { | 110 | if (child_pid) { |
| 110 | /* parent */ | 111 | /* parent */ |
| 111 | #define buf bb_common_bufsiz1 | ||
| 112 | struct pollfd pfd[2]; | 112 | struct pollfd pfd[2]; |
| 113 | int outfd, count, loop; | 113 | int outfd, count, loop; |
| 114 | double oldtime = ENABLE_SCRIPTREPLAY ? time(NULL) : 0; | 114 | double oldtime = ENABLE_SCRIPTREPLAY ? time(NULL) : 0; |
| 115 | smallint fd_count = 2; | 115 | smallint fd_count = 2; |
| 116 | #define buf bb_common_bufsiz1 | ||
| 117 | setup_common_bufsiz(); | ||
| 116 | 118 | ||
| 117 | outfd = xopen(fname, mode); | 119 | outfd = xopen(fname, mode); |
| 118 | pfd[0].fd = pty; | 120 | pfd[0].fd = pty; |
| @@ -134,7 +136,7 @@ int script_main(int argc UNUSED_PARAM, char **argv) | |||
| 134 | } | 136 | } |
| 135 | if (pfd[0].revents) { | 137 | if (pfd[0].revents) { |
| 136 | errno = 0; | 138 | errno = 0; |
| 137 | count = safe_read(pty, buf, sizeof(buf)); | 139 | count = safe_read(pty, buf, COMMON_BUFSIZE); |
| 138 | if (count <= 0 && errno != EAGAIN) { | 140 | if (count <= 0 && errno != EAGAIN) { |
| 139 | /* err/eof from pty: exit */ | 141 | /* err/eof from pty: exit */ |
| 140 | goto restore; | 142 | goto restore; |
| @@ -157,7 +159,7 @@ int script_main(int argc UNUSED_PARAM, char **argv) | |||
| 157 | } | 159 | } |
| 158 | } | 160 | } |
| 159 | if (pfd[1].revents) { | 161 | if (pfd[1].revents) { |
| 160 | count = safe_read(STDIN_FILENO, buf, sizeof(buf)); | 162 | count = safe_read(STDIN_FILENO, buf, COMMON_BUFSIZE); |
| 161 | if (count <= 0) { | 163 | if (count <= 0) { |
| 162 | /* err/eof from stdin: don't read stdin anymore */ | 164 | /* err/eof from stdin: don't read stdin anymore */ |
| 163 | pfd[1].revents = 0; | 165 | pfd[1].revents = 0; |
| @@ -176,7 +178,7 @@ int script_main(int argc UNUSED_PARAM, char **argv) | |||
| 176 | * (util-linux's script doesn't do this. buggy :) */ | 178 | * (util-linux's script doesn't do this. buggy :) */ |
| 177 | loop = 999; | 179 | loop = 999; |
| 178 | /* pty is in O_NONBLOCK mode, we exit as soon as buffer is empty */ | 180 | /* pty is in O_NONBLOCK mode, we exit as soon as buffer is empty */ |
| 179 | while (--loop && (count = safe_read(pty, buf, sizeof(buf))) > 0) { | 181 | while (--loop && (count = safe_read(pty, buf, COMMON_BUFSIZE)) > 0) { |
| 180 | full_write(STDOUT_FILENO, buf, count); | 182 | full_write(STDOUT_FILENO, buf, count); |
| 181 | full_write(outfd, buf, count); | 183 | full_write(outfd, buf, count); |
| 182 | } | 184 | } |
