• R/O
  • SSH
  • HTTPS

yash: Commit


Commit MetaInfo

Revision4012 (tree)
Time2019-12-23 23:12:55
Authormagicant

Log Message

Revert "Remove j_nonotify"

This reverts commit e0400605ac29a42ceeed8bcf86fe628a53d67c56.

Commit e040060 mistakenly assumed that the j_nonotify flag had been used
only to prevent the job from being removed, but in reality also from
being reported when the -b shell option is enabled.

As a result of the commit, the job status was being reported redundantly
when a job exits after resumed by the "fg" built-in.

Change Summary

Incremental Difference

--- yash/trunk/NEWS (revision 4011)
+++ yash/trunk/NEWS (revision 4012)
@@ -10,6 +10,9 @@
1010 ----------------------------------------------------------------------
1111 Yash 2.50
1212
13+ * With the "-o notify" option enabled, the "fg" built-in was
14+ redundantly reporting the status of the job that had been resumed
15+ and exited.
1316 * Line-editing no longer hangs when the terminfo database maps a
1417 key to an empty string.
1518 . Updated the sample initialization script (yashrc):
--- yash/trunk/exec.c (revision 4011)
+++ yash/trunk/exec.c (revision 4012)
@@ -351,9 +351,7 @@
351351 job->j_status = JS_RUNNING;
352352 job->j_statuschanged = true;
353353 job->j_legacy = false;
354-#ifndef NDEBUG
355- job->j_beingwaitedfor = false;
356-#endif
354+ job->j_nonotify = false;
357355 job->j_pcount = 1;
358356
359357 set_active_job(job);
@@ -636,9 +634,7 @@
636634 job->j_status = JS_RUNNING;
637635 job->j_statuschanged = true;
638636 job->j_legacy = false;
639-#ifndef NDEBUG
640- job->j_beingwaitedfor = false;
641-#endif
637+ job->j_nonotify = false;
642638 job->j_pcount = count;
643639 set_active_job(job);
644640 if (type == E_NORMAL) {
--- yash/trunk/job.c (revision 4011)
+++ yash/trunk/job.c (revision 4012)
@@ -174,9 +174,6 @@
174174 void free_job(job_T *job)
175175 {
176176 if (job != NULL) {
177-#ifndef NDEBUG
178- assert(!job->j_beingwaitedfor);
179-#endif
180177 for (size_t i = 0; i < job->j_pcount; i++)
181178 free(job->j_procs[i].pr_name);
182179 free(job);
@@ -460,10 +457,8 @@
460457 job_T *job = joblist.contents[jobnumber];
461458
462459 if (!job->j_legacy) {
463-#ifndef NDEBUG
464- assert(!job->j_beingwaitedfor);
465- job->j_beingwaitedfor = true;
466-#endif
460+ bool savenonotify = job->j_nonotify;
461+ job->j_nonotify = true;
467462 for (;;) {
468463 if (job->j_status == JS_DONE)
469464 break;
@@ -473,9 +468,7 @@
473468 if (signum != 0)
474469 break;
475470 }
476-#ifndef NDEBUG
477- job->j_beingwaitedfor = false;
478-#endif
471+ job->j_nonotify = savenonotify;
479472 }
480473 return signum;
481474 }
@@ -502,9 +495,7 @@
502495 job->j_status = JS_RUNNING;
503496 job->j_statuschanged = false;
504497 job->j_legacy = false;
505-#ifndef NDEBUG
506- job->j_beingwaitedfor = false;
507-#endif
498+ job->j_nonotify = false;
508499 job->j_pcount = 1;
509500 job->j_procs[0].pr_pid = cpid;
510501 job->j_procs[0].pr_status = JS_RUNNING;
@@ -748,7 +739,7 @@
748739 {
749740 for (size_t i = 1; i < joblist.length; i++) {
750741 const job_T *job = get_job(i);
751- if (job != NULL && job->j_statuschanged)
742+ if (job != NULL && !job->j_nonotify && job->j_statuschanged)
752743 return true;
753744 }
754745 return false;
@@ -766,11 +757,13 @@
766757 int print_job_status(size_t jobnumber,
767758 bool changedonly, bool verbose, bool remove_done, FILE *f)
768759 {
760+ int result = 0;
761+
769762 job_T *job = get_job(jobnumber);
770- if (job == NULL)
771- return 0;
763+ if (job == NULL || job->j_nonotify)
764+ return result;
772765 if (changedonly && !job->j_statuschanged)
773- return 0;
766+ return result;
774767
775768 char current;
776769 if (jobnumber == current_jobnumber) current = '+';
@@ -777,7 +770,6 @@
777770 else if (jobnumber == previous_jobnumber) current = '-';
778771 else current = ' ';
779772
780- int result;
781773 if (!verbose) {
782774 bool needfree;
783775 char *status = get_job_status_string(job, &needfree);
--- yash/trunk/job.h (revision 4011)
+++ yash/trunk/job.h (revision 4012)
@@ -1,6 +1,6 @@
11 /* Yash: yet another shell */
22 /* job.h: job control */
3-/* (C) 2007-2019 magicant */
3+/* (C) 2007-2017 magicant */
44
55 /* This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
@@ -43,15 +43,13 @@
4343
4444 /* info about a job */
4545 typedef struct job_T {
46- pid_t j_pgid; /* process group ID */
46+ pid_t j_pgid; /* process group ID */
4747 jobstatus_T j_status;
48- _Bool j_statuschanged; /* job's status not yet reported? */
49- _Bool j_legacy; /* not a true child of the shell? */
50-#ifndef NDEBUG
51- _Bool j_beingwaitedfor; /* wait_for_job is awaiting? */
52-#endif
53- size_t j_pcount; /* # of processes in `j_procs' */
54- process_T j_procs[]; /* info about processes */
48+ _Bool j_statuschanged; /* job's status not yet reported? */
49+ _Bool j_legacy; /* not a true child of the shell? */
50+ _Bool j_nonotify; /* suppress printing job status? */
51+ size_t j_pcount; /* # of processes in `j_procs' */
52+ process_T j_procs[]; /* info about processes */
5553 } job_T;
5654 /* When job control is off, `j_pgid' is 0 since the job shares the process group
5755 * ID with the shell.
Show on old repository browser