#include "sh.h"
-__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.121 2016/07/25 00:04:44 tg Exp $");
+__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.124 2017/08/08 14:30:10 tg Exp $");
#if HAVE_KILLPG
#define mksh_killpg killpg
#define PSTOPPED 3
typedef struct proc Proc;
+/* to take alignment into consideration */
+struct proc_dummy {
+ Proc *next;
+ pid_t pid;
+ int state;
+ int status;
+ char command[128];
+};
+/* real structure */
struct proc {
- Proc *next; /* next process in pipeline (if any) */
- pid_t pid; /* process id */
+ /* next process in pipeline (if any) */
+ Proc *next;
+ /* process id of this Unix process in the job */
+ pid_t pid;
+ /* one of the four P… above */
int state;
- int status; /* wait status */
+ /* wait status */
+ int status;
/* process command string from vistree */
- char command[256 - (ALLOC_OVERHEAD + sizeof(Proc *) +
- sizeof(pid_t) + 2 * sizeof(int))];
+ char command[256 - (ALLOC_OVERHEAD +
+ offsetof(struct proc_dummy, command[0]))];
};
/* Notify/print flag - j_print() argument */
}
for (j = job_list; j; j = tmp) {
tmp = j->next;
- if (j->flags & JF_REMOVE)
- remove_job(j, "notify");
+ if (j->flags & JF_REMOVE) {
+ if (j == async_job || (j->flags & JF_KNOWN)) {
+ j->flags = (j->flags & ~JF_REMOVE) | JF_ZOMBIE;
+ j->job = -1;
+ nzombie++;
+ } else
+ remove_job(j, "notify");
+ }
}
shf_flush(shl_out);
#ifndef MKSH_NOPROSPECTOFWORK
size_t len;
int job = 0;
- if (ksh_isdigit(*cp) && getn(cp, &job)) {
+ if (ctype(*cp, C_DIGIT) && getn(cp, &job)) {
/* Look for last_proc->pid (what $! returns) first... */
for (j = job_list; j != NULL; j = j->next)
if (j->last_proc && j->last_proc->pid == job)