*: hopefully all setup_common_bufsiz() are in place
[oweals/busybox.git] / util-linux / script.c
index 6195161bcc8b6ca60909a52b753868b307bbe766..86475c1f145da4e3ae36f937e3a8a7782048dbb4 100644 (file)
@@ -109,12 +109,12 @@ int script_main(int argc UNUSED_PARAM, char **argv)
 
        if (child_pid) {
                /* parent */
-#define        buf bb_common_bufsiz1
-#define sizeof_buf COMMON_BUFSIZE
                struct pollfd pfd[2];
                int outfd, count, loop;
                double oldtime = ENABLE_SCRIPTREPLAY ? time(NULL) : 0;
                smallint fd_count = 2;
+#define buf bb_common_bufsiz1
+               setup_common_bufsiz();
 
                outfd = xopen(fname, mode);
                pfd[0].fd = pty;
@@ -136,7 +136,7 @@ int script_main(int argc UNUSED_PARAM, char **argv)
                        }
                        if (pfd[0].revents) {
                                errno = 0;
-                               count = safe_read(pty, buf, sizeof_buf);
+                               count = safe_read(pty, buf, COMMON_BUFSIZE);
                                if (count <= 0 && errno != EAGAIN) {
                                        /* err/eof from pty: exit */
                                        goto restore;
@@ -159,7 +159,7 @@ int script_main(int argc UNUSED_PARAM, char **argv)
                                }
                        }
                        if (pfd[1].revents) {
-                               count = safe_read(STDIN_FILENO, buf, sizeof_buf);
+                               count = safe_read(STDIN_FILENO, buf, COMMON_BUFSIZE);
                                if (count <= 0) {
                                        /* err/eof from stdin: don't read stdin anymore */
                                        pfd[1].revents = 0;
@@ -178,7 +178,7 @@ int script_main(int argc UNUSED_PARAM, char **argv)
                 * (util-linux's script doesn't do this. buggy :) */
                loop = 999;
                /* pty is in O_NONBLOCK mode, we exit as soon as buffer is empty */
-               while (--loop && (count = safe_read(pty, buf, sizeof_buf)) > 0) {
+               while (--loop && (count = safe_read(pty, buf, COMMON_BUFSIZE)) > 0) {
                        full_write(STDOUT_FILENO, buf, count);
                        full_write(outfd, buf, count);
                }