• R/O
  • SSH
  • HTTPS

yash: Commit


Commit MetaInfo

Revision3968 (tree)
Time2019-01-14 00:45:29
Authormagicant

Log Message

Remove j_nonotify

Now print_job_status_all does not remove printed jobs, we don't need to
protect a job that is being awaited by wait_for_job. Hence the
j_nonotify flag is removed. The j_beingwaitedfor flag, only used for
assertions, is added in place of it.

Change Summary

Incremental Difference

--- yash/trunk/exec.c (revision 3967)
+++ yash/trunk/exec.c (revision 3968)
@@ -1,6 +1,6 @@
11 /* Yash: yet another shell */
22 /* exec.c: command execution */
3-/* (C) 2007-2018 magicant */
3+/* (C) 2007-2019 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
@@ -350,7 +350,9 @@
350350 job->j_status = JS_RUNNING;
351351 job->j_statuschanged = true;
352352 job->j_legacy = false;
353- job->j_nonotify = false;
353+#ifndef NDEBUG
354+ job->j_beingwaitedfor = false;
355+#endif
354356 job->j_pcount = 1;
355357
356358 set_active_job(job);
@@ -628,7 +630,9 @@
628630 job->j_status = JS_RUNNING;
629631 job->j_statuschanged = true;
630632 job->j_legacy = false;
631- job->j_nonotify = false;
633+#ifndef NDEBUG
634+ job->j_beingwaitedfor = false;
635+#endif
632636 job->j_pcount = count;
633637 set_active_job(job);
634638 if (type == E_NORMAL) {
--- yash/trunk/job.c (revision 3967)
+++ yash/trunk/job.c (revision 3968)
@@ -1,6 +1,6 @@
11 /* Yash: yet another shell */
22 /* job.c: job control */
3-/* (C) 2007-2017 magicant */
3+/* (C) 2007-2019 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
@@ -173,6 +173,9 @@
173173 void free_job(job_T *job)
174174 {
175175 if (job != NULL) {
176+#ifndef NDEBUG
177+ assert(!job->j_beingwaitedfor);
178+#endif
176179 for (size_t i = 0; i < job->j_pcount; i++)
177180 free(job->j_procs[i].pr_name);
178181 free(job);
@@ -455,8 +458,10 @@
455458 job_T *job = joblist.contents[jobnumber];
456459
457460 if (!job->j_legacy) {
458- bool savenonotify = job->j_nonotify;
459- job->j_nonotify = true;
461+#ifndef NDEBUG
462+ assert(!job->j_beingwaitedfor);
463+ job->j_beingwaitedfor = true;
464+#endif
460465 for (;;) {
461466 if (job->j_status == JS_DONE)
462467 break;
@@ -466,7 +471,9 @@
466471 if (signum != 0)
467472 break;
468473 }
469- job->j_nonotify = savenonotify;
474+#ifndef NDEBUG
475+ job->j_beingwaitedfor = false;
476+#endif
470477 }
471478 return signum;
472479 }
@@ -493,7 +500,9 @@
493500 job->j_status = JS_RUNNING;
494501 job->j_statuschanged = false;
495502 job->j_legacy = false;
496- job->j_nonotify = false;
503+#ifndef NDEBUG
504+ job->j_beingwaitedfor = false;
505+#endif
497506 job->j_pcount = 1;
498507 job->j_procs[0].pr_pid = cpid;
499508 job->j_procs[0].pr_status = JS_RUNNING;
@@ -737,7 +746,7 @@
737746 {
738747 for (size_t i = 1; i < joblist.length; i++) {
739748 const job_T *job = get_job(i);
740- if (job != NULL && !job->j_nonotify && job->j_statuschanged)
749+ if (job != NULL && job->j_statuschanged)
741750 return true;
742751 }
743752 return false;
@@ -755,13 +764,11 @@
755764 int print_job_status(size_t jobnumber,
756765 bool changedonly, bool verbose, bool remove_done, FILE *f)
757766 {
758- int result = 0;
759-
760767 job_T *job = get_job(jobnumber);
761- if (job == NULL || job->j_nonotify)
762- return result;
768+ if (job == NULL)
769+ return 0;
763770 if (changedonly && !job->j_statuschanged)
764- return result;
771+ return 0;
765772
766773 char current;
767774 if (jobnumber == current_jobnumber) current = '+';
@@ -768,6 +775,7 @@
768775 else if (jobnumber == previous_jobnumber) current = '-';
769776 else current = ' ';
770777
778+ int result;
771779 if (!verbose) {
772780 bool needfree;
773781 char *status = get_job_status_string(job, &needfree);
--- yash/trunk/job.h (revision 3967)
+++ yash/trunk/job.h (revision 3968)
@@ -1,6 +1,6 @@
11 /* Yash: yet another shell */
22 /* job.h: job control */
3-/* (C) 2007-2017 magicant */
3+/* (C) 2007-2019 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,13 +43,15 @@
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- _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 */
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 */
5355 } job_T;
5456 /* When job control is off, `j_pgid' is 0 since the job shares the process group
5557 * ID with the shell.
Show on old repository browser