aboutsummaryrefslogtreecommitdiff
path: root/util-linux/script.c
diff options
context:
space:
mode:
Diffstat (limited to 'util-linux/script.c')
-rw-r--r--util-linux/script.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/util-linux/script.c b/util-linux/script.c
index abcd73bff..6195161bc 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
27int script_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 28int script_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
28int script_main(int argc UNUSED_PARAM, char **argv) 29int script_main(int argc UNUSED_PARAM, char **argv)
@@ -108,7 +109,8 @@ 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#define buf bb_common_bufsiz1
113#define sizeof_buf COMMON_BUFSIZE
112 struct pollfd pfd[2]; 114 struct pollfd pfd[2];
113 int outfd, count, loop; 115 int outfd, count, loop;
114 double oldtime = ENABLE_SCRIPTREPLAY ? time(NULL) : 0; 116 double oldtime = ENABLE_SCRIPTREPLAY ? time(NULL) : 0;
@@ -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, sizeof_buf);
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, sizeof_buf);
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, sizeof_buf)) > 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 }