*/
/*
- Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
+ Copyright (C) 2002-2004 Kern Sibbald and John Walker
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
return NULL;
}
if (mode_read && pipe(readp) == -1) {
+ if (mode_write) {
+ close(writep[0]);
+ close(writep[1]);
+ }
free(bpipe);
return NULL;
}
/* Start worker process */
switch (bpipe->worker_pid = fork()) {
case -1: /* error */
+ if (mode_write) {
+ close(writep[0]);
+ close(writep[1]);
+ }
+ if (mode_read) {
+ close(readp[0]);
+ close(readp[1]);
+ }
free(bpipe);
return NULL;
dup2(readp[1], 1); /* dup our read to his stdout */
dup2(readp[1], 2); /* and his stderr */
}
- for (i=3; i<=32; i++) { /* close any open file descriptors */
+ closelog(); /* close syslog if open */
+ for (i=3; i<=32; i++) { /* close any open file descriptors */
close(i);
}
execvp(bargv[0], bargv); /* call the program */
if (WIFEXITED(chldstatus)) { /* process exit()ed */
stat = WEXITSTATUS(chldstatus);
if (stat != 0) {
+ Dmsg1(100, "Non-zero status %s returned from child.\n", stat);
stat = ECHILD;
}
Dmsg1(200, "child status=%d\n", stat);