aboutsummaryrefslogtreecommitdiff
path: root/busybox/coreutils/watch.c
diff options
context:
space:
mode:
Diffstat (limited to 'busybox/coreutils/watch.c')
-rw-r--r--busybox/coreutils/watch.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/busybox/coreutils/watch.c b/busybox/coreutils/watch.c
index f9f40189e..31fadfb85 100644
--- a/busybox/coreutils/watch.c
+++ b/busybox/coreutils/watch.c
@@ -82,7 +82,7 @@ extern int watch_main(int argc, char **argv)
82 header[len] = 0; 82 header[len] = 0;
83 83
84 /* thanks to lye, who showed me how to redirect stdin/stdout */ 84 /* thanks to lye, who showed me how to redirect stdin/stdout */
85 old_stdout = dup(1); 85 old_stdout = dup(STDOUT_FILENO);
86 86
87 while (1) { 87 while (1) {
88 time(&t); 88 time(&t);
@@ -98,13 +98,11 @@ extern int watch_main(int argc, char **argv)
98 sleep(period); 98 sleep(period);
99 } else if (0 == pid) { 99 } else if (0 == pid) {
100 //child 100 //child
101 close(1); 101 dup2(old_stdout, STDOUT_FILENO);
102 dup(old_stdout); 102 execvp(*watched_argv, watched_argv);
103 if (execvp(*watched_argv, watched_argv)) { 103 bb_perror_msg_and_die(*watched_argv);
104 bb_error_msg_and_die("Couldn't run command\n");
105 }
106 } else { 104 } else {
107 bb_error_msg_and_die("Couldn't vfork\n"); 105 bb_perror_msg_and_die("vfork");
108 } 106 }
109 } 107 }
110} 108}