summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shell/ash.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/shell/ash.c b/shell/ash.c
index ccb1e1a..6173a25 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -3141,20 +3141,18 @@ struct job {
};
static pid_t backgndpid; /* pid of last background process */
-static int job_warning; /* user was warned about stopped jobs */
-#if JOBS
-static int jobctl; /* true if doing job control */
-#endif
+static smallint job_warning; /* user was warned about stopped jobs (can be 2, 1 or 0). */
static struct job *makejob(union node *, int);
static int forkshell(struct job *, union node *, int);
static int waitforjob(struct job *);
-#if ! JOBS
-#define setjobctl(on) /* do nothing */
+#if !JOBS
+enum { jobctl = 0 };
+#define setjobctl(on) do {} while (0)
#else
+static smallint jobctl; /* true if doing job control */
static void setjobctl(int);
-static void showjobs(FILE *, int);
#endif
/*
@@ -3836,11 +3834,32 @@ showjob(FILE *out, struct job *jp, int mode)
}
}
+/*
+ * Print a list of jobs. If "change" is nonzero, only print jobs whose
+ * statuses have changed since the last call to showjobs.
+ */
+static void
+showjobs(FILE *out, int mode)
+{
+ struct job *jp;
+
+ TRACE(("showjobs(%x) called\n", mode));
+
+ /* If not even one one job changed, there is nothing to do */
+ while (dowait(DOWAIT_NORMAL, NULL) > 0)
+ continue;
+
+ for (jp = curjob; jp; jp = jp->prev_job) {
+ if (!(mode & SHOW_CHANGED) || jp->changed) {
+ showjob(out, jp, mode);
+ }
+ }
+}
+
static int
jobscmd(int argc, char **argv)
{
int mode, m;
- FILE *out;
mode = 0;
while ((m = nextopt("lp"))) {
@@ -3850,38 +3869,16 @@ jobscmd(int argc, char **argv)
mode = SHOW_PGID;
}
- out = stdout;
argv = argptr;
if (*argv) {
do
- showjob(out, getjob(*argv,0), mode);
+ showjob(stdout, getjob(*argv,0), mode);
while (*++argv);
} else
- showjobs(out, mode);
+ showjobs(stdout, mode);
return 0;
}
-
-/*
- * Print a list of jobs. If "change" is nonzero, only print jobs whose
- * statuses have changed since the last call to showjobs.
- */
-static void
-showjobs(FILE *out, int mode)
-{
- struct job *jp;
-
- TRACE(("showjobs(%x) called\n", mode));
-
- /* If not even one one job changed, there is nothing to do */
- while (dowait(DOWAIT_NORMAL, NULL) > 0)
- continue;
-
- for (jp = curjob; jp; jp = jp->prev_job) {
- if (!(mode & SHOW_CHANGED) || jp->changed)
- showjob(out, jp, mode);
- }
-}
#endif /* JOBS */
static int
@@ -4043,6 +4040,8 @@ makejob(union node *node, int nprocs)
}
memset(jp, 0, sizeof(*jp));
#if JOBS
+ /* jp->jobctl is a bitfield.
+ * "jp->jobctl |= jobctl" likely to give awful code */
if (jobctl)
jp->jobctl = 1;
#endif
@@ -10883,7 +10882,8 @@ cmdloop(int top)
}
numeof++;
} else if (nflag == 0) {
- job_warning = (job_warning == 2) ? 1 : 0;
+ /* job_warning can only be 2,1,0. Here 2->1, 1/0->0 */
+ job_warning >>= 1;
numeof = 0;
evaltree(n, 0);
}