patch by Shaun Jackman to combine dup/close funcs into dup2
This commit is contained in:
parent
8804c6a3b7
commit
a87bb60809
@ -82,7 +82,7 @@ extern int watch_main(int argc, char **argv)
|
|||||||
header[len] = 0;
|
header[len] = 0;
|
||||||
|
|
||||||
/* thanks to lye, who showed me how to redirect stdin/stdout */
|
/* thanks to lye, who showed me how to redirect stdin/stdout */
|
||||||
old_stdout = dup(1);
|
old_stdout = dup(STDOUT_FILENO);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
time(&t);
|
time(&t);
|
||||||
@ -98,8 +98,7 @@ extern int watch_main(int argc, char **argv)
|
|||||||
sleep(period);
|
sleep(period);
|
||||||
} else if (0 == pid) {
|
} else if (0 == pid) {
|
||||||
//child
|
//child
|
||||||
close(1);
|
dup2(old_stdout, STDOUT_FILENO);
|
||||||
dup(old_stdout);
|
|
||||||
execvp(*watched_argv, watched_argv);
|
execvp(*watched_argv, watched_argv);
|
||||||
bb_perror_msg_and_die(*watched_argv);
|
bb_perror_msg_and_die(*watched_argv);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user