version 1.260, 2020/10/05 19:27:47 |
version 1.261, 2020/10/05 21:37:07 |
Line 290 static char *shellArgv = NULL; /* Custom |
|
Line 290 static char *shellArgv = NULL; /* Custom |
|
|
|
STATIC Job *job_table; /* The structures that describe them */ |
STATIC Job *job_table; /* The structures that describe them */ |
STATIC Job *job_table_end; /* job_table + maxJobs */ |
STATIC Job *job_table_end; /* job_table + maxJobs */ |
static int wantToken; /* we want a token */ |
static unsigned int wantToken; /* we want a token */ |
static int lurking_children = 0; |
static int lurking_children = 0; |
static int make_suspended = 0; /* non-zero if we've seen a SIGTSTP (etc) */ |
static int make_suspended = 0; /* non-zero if we've seen a SIGTSTP (etc) */ |
|
|
Line 300 static int make_suspended = 0; /* non-ze |
|
Line 300 static int make_suspended = 0; /* non-ze |
|
*/ |
*/ |
static struct pollfd *fds = NULL; |
static struct pollfd *fds = NULL; |
static Job **jobfds = NULL; |
static Job **jobfds = NULL; |
static int nfds = 0; |
static nfds_t nfds = 0; |
static void watchfd(Job *); |
static void watchfd(Job *); |
static void clearfd(Job *); |
static void clearfd(Job *); |
static int readyfd(Job *); |
static int readyfd(Job *); |
Line 314 static Job childExitJob; /* child exit p |
|
Line 314 static Job childExitJob; /* child exit p |
|
#define CHILD_EXIT "." |
#define CHILD_EXIT "." |
#define DO_JOB_RESUME "R" |
#define DO_JOB_RESUME "R" |
|
|
static const int npseudojobs = 2; /* number of pseudo-jobs */ |
enum { npseudojobs = 2 }; /* number of pseudo-jobs */ |
|
|
#define TARG_FMT "%s %s ---\n" /* Default format */ |
#define TARG_FMT "%s %s ---\n" /* Default format */ |
#define MESSAGE(fp, gn) \ |
#define MESSAGE(fp, gn) \ |
Line 1648 JobDoOutput(Job *job, Boolean finish) |
|
Line 1648 JobDoOutput(Job *job, Boolean finish) |
|
{ |
{ |
Boolean gotNL = FALSE; /* true if got a newline */ |
Boolean gotNL = FALSE; /* true if got a newline */ |
Boolean fbuf; /* true if our buffer filled up */ |
Boolean fbuf; /* true if our buffer filled up */ |
int nr; /* number of bytes read */ |
size_t nr; /* number of bytes read */ |
int i; /* auxiliary index into outBuf */ |
size_t i; /* auxiliary index into outBuf */ |
int max; /* limit for i (end of current data) */ |
size_t max; /* limit for i (end of current data) */ |
int nRead; /* (Temporary) number of bytes read */ |
ssize_t nRead; /* (Temporary) number of bytes read */ |
|
|
/* |
/* |
* Read as many bytes as will fit in the buffer. |
* Read as many bytes as will fit in the buffer. |
|
|
} |
} |
nr = 0; |
nr = 0; |
} else { |
} else { |
nr = nRead; |
nr = (size_t)nRead; |
} |
} |
|
|
/* |
/* |
|
|
* TRUE. |
* TRUE. |
*/ |
*/ |
max = job->curPos + nr; |
max = job->curPos + nr; |
for (i = job->curPos + nr - 1; i >= job->curPos; i--) { |
for (i = job->curPos + nr - 1; i >= job->curPos && i != (size_t)-1; i--) { |
if (job->outBuf[i] == '\n') { |
if (job->outBuf[i] == '\n') { |
gotNL = TRUE; |
gotNL = TRUE; |
break; |
break; |
Line 1892 Job_CatchOutput(void) |
|
Line 1892 Job_CatchOutput(void) |
|
{ |
{ |
int nready; |
int nready; |
Job *job; |
Job *job; |
int i; |
unsigned int i; |
|
|
(void)fflush(stdout); |
(void)fflush(stdout); |
|
|
Line 1926 Job_CatchOutput(void) |
|
Line 1926 Job_CatchOutput(void) |
|
|
|
Job_CatchChildren(); |
Job_CatchChildren(); |
if (nready == 0) |
if (nready == 0) |
return; |
return; |
|
|
for (i = npseudojobs*nfds_per_job(); i < nfds; i++) { |
for (i = npseudojobs * nfds_per_job(); i < nfds; i++) { |
if (!fds[i].revents) |
if (!fds[i].revents) |
continue; |
continue; |
job = jobfds[i]; |
job = jobfds[i]; |
Line 1947 Job_CatchOutput(void) |
|
Line 1947 Job_CatchOutput(void) |
|
} |
} |
#endif |
#endif |
if (--nready == 0) |
if (--nready == 0) |
return; |
return; |
} |
} |
} |
} |
|
|
Line 1991 Shell_Init(void) |
|
Line 1991 Shell_Init(void) |
|
shellErrFlag = NULL; |
shellErrFlag = NULL; |
} |
} |
if (!shellErrFlag) { |
if (!shellErrFlag) { |
int n = strlen(commandShell->exit) + 2; |
size_t n = strlen(commandShell->exit) + 2; |
|
|
shellErrFlag = bmake_malloc(n); |
shellErrFlag = bmake_malloc(n); |
if (shellErrFlag) { |
if (shellErrFlag) { |
|
|
{ |
{ |
Job_SetPrefix(); |
Job_SetPrefix(); |
/* Allocate space for all the job info */ |
/* Allocate space for all the job info */ |
job_table = bmake_malloc(maxJobs * sizeof *job_table); |
job_table = bmake_malloc((size_t)maxJobs * sizeof *job_table); |
memset(job_table, 0, maxJobs * sizeof *job_table); |
memset(job_table, 0, (size_t)maxJobs * sizeof *job_table); |
job_table_end = job_table + maxJobs; |
job_table_end = job_table + maxJobs; |
wantToken = 0; |
wantToken = 0; |
|
|
|
|
|
|
/* Preallocate enough for the maximum number of jobs. */ |
/* Preallocate enough for the maximum number of jobs. */ |
fds = bmake_malloc(sizeof(*fds) * |
fds = bmake_malloc(sizeof(*fds) * |
(npseudojobs + maxJobs) * nfds_per_job()); |
(npseudojobs + (size_t)maxJobs) * nfds_per_job()); |
jobfds = bmake_malloc(sizeof(*jobfds) * |
jobfds = bmake_malloc(sizeof(*jobfds) * |
(npseudojobs + maxJobs) * nfds_per_job()); |
(npseudojobs + (size_t)maxJobs) * nfds_per_job()); |
|
|
/* These are permanent entries and take slots 0 and 1 */ |
/* These are permanent entries and take slots 0 and 1 */ |
watchfd(&tokenWaitJob); |
watchfd(&tokenWaitJob); |
Line 2521 watchfd(Job *job) |
|
Line 2521 watchfd(Job *job) |
|
static void |
static void |
clearfd(Job *job) |
clearfd(Job *job) |
{ |
{ |
int i; |
size_t i; |
if (job->inPollfd == NULL) |
if (job->inPollfd == NULL) |
Punt("Unwatching unwatched job"); |
Punt("Unwatching unwatched job"); |
i = job->inPollfd - fds; |
i = (size_t)(job->inPollfd - fds); |
nfds--; |
nfds--; |
#if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV) |
#if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV) |
if (useMeta) { |
if (useMeta) { |
|
|
Job_TokenWithdraw(void) |
Job_TokenWithdraw(void) |
{ |
{ |
char tok, tok1; |
char tok, tok1; |
int count; |
ssize_t count; |
|
|
wantToken = 0; |
wantToken = 0; |
DEBUG3(JOB, "Job_TokenWithdraw(%d): aborting %d, running %d\n", |
DEBUG3(JOB, "Job_TokenWithdraw(%d): aborting %d, running %d\n", |