diff options
author | Bill Nottingham <notting@redhat.com> | 1999-08-19 18:51:12 +0000 |
---|---|---|
committer | Bill Nottingham <notting@redhat.com> | 1999-08-19 18:51:12 +0000 |
commit | 8ff50eae943a153365b4cfac783a9fe96d4808a6 (patch) | |
tree | 943c5b8b7b4a20edfa6b6861170d5edc3ff24738 | |
parent | d6cd1bbc5f06dd37b841c99de69fcb9bbabb4eff (diff) | |
download | initscripts-8ff50eae943a153365b4cfac783a9fe96d4808a6.tar initscripts-8ff50eae943a153365b4cfac783a9fe96d4808a6.tar.gz initscripts-8ff50eae943a153365b4cfac783a9fe96d4808a6.tar.bz2 initscripts-8ff50eae943a153365b4cfac783a9fe96d4808a6.tar.xz initscripts-8ff50eae943a153365b4cfac783a9fe96d4808a6.zip |
I don't remember smoking crack, but I must have been...r4-30
-rw-r--r-- | src/process.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/process.c b/src/process.c index 8afb4392..ef7d9e26 100644 --- a/src/process.c +++ b/src/process.c @@ -114,7 +114,7 @@ int forkCommand(char **args, int *outfd, int *errfd, int *cmdfd, int quiet) { int monitor(char *cmdname, int pid, int numfds, int *fds, int reexec, int quiet, int debug) { struct pollfd *pfds; char *buf=malloc(8192*sizeof(char)); - int outpipe[2]; + char *outbuf=NULL; char *tmpstr=NULL; int x,y,rc=-1; int done=0; @@ -129,8 +129,6 @@ int monitor(char *cmdname, int pid, int numfds, int *fds, int reexec, int quiet, snprintf(procpath,20,"/proc/%d",pid); } - pipe(outpipe); - pfds = malloc(numfds*sizeof(struct pollfd)); for (x=0;x<numfds;x++) { pfds[x].fd = fds[x]; @@ -168,8 +166,10 @@ int monitor(char *cmdname, int pid, int numfds, int *fds, int reexec, int quiet, if (!quiet && !reexec) write(1,buf,bytesread); if (quiet) { - output = 1; - write(outpipe[1],buf,bytesread); + outbuf=realloc(outbuf,(outbuf ? strlen(outbuf)+bytesread+1 : bytesread+1)); + if (!output) outbuf[0]='\0'; + strcat(outbuf,buf); + output = 1; } while ((tmpstr=getLine(&buf))) { int ignore=0; @@ -228,13 +228,7 @@ int monitor(char *cmdname, int pid, int numfds, int *fds, int reexec, int quiet, /* If there was an error and we're quiet, be loud */ if (quiet && output) { - buf=calloc(8192,sizeof(char)); - do { - x=read(outpipe[0],buf,8192); - write(1,"\n",1); - write(1,buf,x); - buf=calloc(8192,sizeof(char)); - } while (x==8192); + write(1,outbuf,strlen(outbuf)); } return (rc); } |