version 1.68, 2007/09/17 09:28:36 |
version 1.69, 2007/09/17 10:17:26 |
|
|
#include <errno.h> |
#include <errno.h> |
#include <fcntl.h> |
#include <fcntl.h> |
#include <signal.h> |
#include <signal.h> |
#include <stddef.h> |
#include <stdarg.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
|
* commands in the Makefile*/ |
* commands in the Makefile*/ |
static char *shellPath = NULL, /* full pathname of |
static char *shellPath = NULL, /* full pathname of |
* executable image */ |
* executable image */ |
*shellName = NULL, /* last component of shell */ |
*shellName = NULL; /* last component of shell */ |
*shellArgv = NULL; /* Custom shell args */ |
|
|
|
|
|
static int maxJobs; /* The most children we can run at once */ |
static int maxJobs; /* The most children we can run at once */ |
|
|
static void JobDoOutput(Job *, bool); |
static void JobDoOutput(Job *, bool); |
static void JobInterrupt(int, int); |
static void JobInterrupt(int, int); |
static void JobRestartJobs(void); |
static void JobRestartJobs(void); |
|
static void DBPRINTF(Job *, const char *, ...); |
|
|
static volatile sig_atomic_t got_SIGINT, got_SIGHUP, got_SIGQUIT, |
static volatile sig_atomic_t got_SIGINT, got_SIGHUP, got_SIGQUIT, |
got_SIGTERM; |
got_SIGTERM; |
|
|
return *(pid_t *)pid - ((Job *)job)->pid; |
return *(pid_t *)pid - ((Job *)job)->pid; |
} |
} |
|
|
|
static void |
|
DBPRINTF(Job *job, const char *fmt, ...) |
|
{ |
|
va_list va; |
|
va_start(va, fmt); |
|
if (DEBUG(JOB)) { |
|
(void)vfprintf(stdout, fmt, va); |
|
fflush(stdout); |
|
} |
|
vfprintf(job->cmdFILE, fmt, va); |
|
va_end(va); |
|
} |
|
|
/*- |
/*- |
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
* JobPrintCommand -- |
* JobPrintCommand -- |
|
|
return 1; |
return 1; |
} |
} |
|
|
#define DBPRINTF(fmt, arg) if (DEBUG(JOB)) { \ |
|
(void)fprintf(stdout, fmt, arg); \ |
|
(void)fflush(stdout); \ |
|
} \ |
|
(void)fprintf(job->cmdFILE, fmt, arg); \ |
|
(void)fflush(job->cmdFILE); |
|
|
|
numCommands++; |
numCommands++; |
|
|
/* For debugging, we replace each command with the result of expanding |
/* For debugging, we replace each command with the result of expanding |
|
|
if (shutUp) { |
if (shutUp) { |
if (!(job->flags & JOB_SILENT) && !noSpecials && |
if (!(job->flags & JOB_SILENT) && !noSpecials && |
commandShell->hasEchoCtl) { |
commandShell->hasEchoCtl) { |
DBPRINTF("%s\n", commandShell->echoOff); |
DBPRINTF(job, "%s\n", commandShell->echoOff); |
} else { |
} else { |
shutUp = false; |
shutUp = false; |
} |
} |
|
|
*/ |
*/ |
if (!(job->flags & JOB_SILENT) && !shutUp && |
if (!(job->flags & JOB_SILENT) && !shutUp && |
commandShell->hasEchoCtl) { |
commandShell->hasEchoCtl) { |
DBPRINTF("%s\n", commandShell->echoOff); |
DBPRINTF(job, "%s\n", commandShell->echoOff); |
DBPRINTF("%s\n", commandShell->ignErr); |
DBPRINTF(job, "%s\n", commandShell->ignErr); |
DBPRINTF("%s\n", commandShell->echoOn); |
DBPRINTF(job, "%s\n", commandShell->echoOn); |
} else { |
} else { |
DBPRINTF("%s\n", commandShell->ignErr); |
DBPRINTF(job, "%s\n", commandShell->ignErr); |
} |
} |
} else if (commandShell->ignErr && |
} else if (commandShell->ignErr && |
(*commandShell->ignErr != '\0')) { |
(*commandShell->ignErr != '\0')) { |
|
|
*/ |
*/ |
if (!(job->flags & JOB_SILENT) && !shutUp && |
if (!(job->flags & JOB_SILENT) && !shutUp && |
commandShell->hasEchoCtl) { |
commandShell->hasEchoCtl) { |
DBPRINTF("%s\n", commandShell->echoOff); |
DBPRINTF(job, "%s\n", commandShell->echoOff); |
DBPRINTF(commandShell->errCheck, cmd); |
DBPRINTF(job, commandShell->errCheck, cmd); |
shutUp = true; |
shutUp = true; |
} |
} |
cmdTemplate = commandShell->ignErr; |
cmdTemplate = commandShell->ignErr; |
|
|
} |
} |
} |
} |
|
|
DBPRINTF(cmdTemplate, cmd); |
DBPRINTF(job, cmdTemplate, cmd); |
|
|
if (errOff) { |
if (errOff) { |
/* |
/* |
|
|
*/ |
*/ |
if (!shutUp && !(job->flags & JOB_SILENT) && |
if (!shutUp && !(job->flags & JOB_SILENT) && |
commandShell->hasEchoCtl){ |
commandShell->hasEchoCtl){ |
DBPRINTF("%s\n", commandShell->echoOff); |
DBPRINTF(job, "%s\n", commandShell->echoOff); |
shutUp = true; |
shutUp = true; |
} |
} |
DBPRINTF("%s\n", commandShell->errCheck); |
DBPRINTF(job, "%s\n", commandShell->errCheck); |
} |
} |
if (shutUp) { |
if (shutUp) { |
DBPRINTF("%s\n", commandShell->echoOn); |
DBPRINTF(job, "%s\n", commandShell->echoOn); |
} |
} |
return 1; |
return 1; |
} |
} |