fd_set rfds;
int maxfd;
int eof = 0;
- char stdoutstr[32], stderrstr[32], indent[16] = { " " };
- indent[get_parent_count() + 1] = 0;
-
if ((child = do_fork()))
return child;
child = run_piped(cmd, argv, NULL, &ofd, &efd);
- snprintf(stdoutstr, 32, "%sstdout", green_color);
- snprintf(stderrstr, 32, "%sstderr", red_color);
FD_ZERO(&rfds);
FD_SET(ofd, &rfds);
char *sptr , *eptr;
char rbuf[BUF_SIZE];
int bytes;
- char *typestr;
+ int is_stderr = 0;
maxfd = max(ofd, efd);
error = select(maxfd, &rfds, NULL, NULL, NULL);
}
if (FD_ISSET(ofd, &rfds)) {
- typestr = stdoutstr;
bytes = read(ofd, rbuf, BUF_SIZE);
goto print;
}
if (FD_ISSET(efd, &rfds)) {
- typestr = stderrstr;
+ is_stderr = 1;
bytes = read(efd, rbuf, BUF_SIZE);
goto print;
}
*/
if (bytes == 0) {
bytes = read(efd, rbuf, BUF_SIZE);
- typestr = stderrstr;
+ is_stderr = 1;
eof = 1;
}
while(bytes--) {
if (*eptr == '\n') {
*eptr = 0;
- fprintf(stderr, "%s[%5d %s] %s: %s%s\n", indent,
- child, cmd, typestr, sptr, normal_color);
+ if (is_stderr)
+ pr_err("%s: stderr: %s\n",
+ cmd, sptr);
+ else
+ pr_info("%s: stdout: %s\n",
+ cmd, sptr);
sptr = eptr;
}
eptr++;