diff options
author | Bill Nottingham <notting@redhat.com> | 1999-06-21 22:33:52 +0000 |
---|---|---|
committer | Bill Nottingham <notting@redhat.com> | 1999-06-21 22:33:52 +0000 |
commit | 928e318914ce5e5f8678fa87c4d4404d28a95a89 (patch) | |
tree | 95f690744e953bf144f1d918ed5ed3a5c91b38ad /src | |
parent | ef8617e6c8f2cb1f74fdc730db6a9943b4f3e91a (diff) | |
download | initscripts-928e318914ce5e5f8678fa87c4d4404d28a95a89.tar initscripts-928e318914ce5e5f8678fa87c4d4404d28a95a89.tar.gz initscripts-928e318914ce5e5f8678fa87c4d4404d28a95a89.tar.bz2 initscripts-928e318914ce5e5f8678fa87c4d4404d28a95a89.tar.xz initscripts-928e318914ce5e5f8678fa87c4d4404d28a95a89.zip |
fix bug in parsing command arguments
Diffstat (limited to 'src')
-rw-r--r-- | src/process.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/process.c b/src/process.c index 0681b8f4..ccde94cc 100644 --- a/src/process.c +++ b/src/process.c @@ -105,6 +105,9 @@ int monitor(char *cmdname, int pid, int numfds, int *fds, int reexec, int quiet, int x,y,rc=-1; int done=0; int output=0; + char **cmdargs=NULL; + char **tmpargs=NULL; + int cmdargc; pipe(outpipe); @@ -153,15 +156,15 @@ int monitor(char *cmdname, int pid, int numfds, int *fds, int reexec, int quiet, logString(cmdname,tmpstr); } } else { - char **cmdargs=NULL; - char **tmpargs=NULL; - int cmdargc,x; + cmdargs=NULL; + tmpargs=NULL; + cmdargc=0; poptParseArgvString(tmpstr,&cmdargc,&tmpargs); - cmdargs=malloc( (cmdargc++) * sizeof(char *) ); + cmdargs=malloc( (cmdargc+1) * sizeof(char *) ); cmdargs[0]=strdup("initlog"); - for (x=0;x<(cmdargc-1);x++) { - cmdargs[x+1]=tmpargs[x]; + for (z=0;z<(cmdargc);z++) { + cmdargs[z+1]=tmpargs[z]; } processArgs(cmdargc,cmdargs,1); } @@ -175,7 +178,6 @@ int monitor(char *cmdname, int pid, int numfds, int *fds, int reexec, int quiet, } if ((!WIFEXITED(rc)) || (rc=WEXITSTATUS(rc))) { /* If there was an error and we're quiet, be loud */ - int x; if (quiet && output) { buf=calloc(2048,sizeof(char)); |