Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Background jobs with no job control / disown bug?



It occurred to me that one way of avoiding a background job getting
job control (disown is not a sufficient method in a function) is to
unsetopt MONITOR, spawn the job, then setopt MONITOR again.  This
nearly works.  Unfortunately,

% unsetopt monitor
% sleep 30 &
% setopt monitor
% jobs
[1] + running

i.e. it's still in the job table (but you'll find you can't do
anything with it).  I suggest deleting jobs from the job table when
this is the case.  I believe the following patch to spawnjob() to
delete the job table entry will fix this.

I should like to hear from someone who knows something about job
control whether this is right.  For example, is it correct (as I
believe) to delete the process structures etc. as well as the job
table entry as deletejob() does?  Is this going to have some dire
effect on some pipeline I don't know about (reading exec.c it seems
like everything does)?

(If it is correct and the job's associated structures need deleting,
then why doesn't disown seem to do this, instead of simply zeroing the
job entry?  I don't think we can both be right.  See bin_fg() in builtin.c)

*** Src/jobs.c~	Sun Oct 29 11:50:22 1995
--- Src/jobs.c	Fri Nov  3 12:06:38 1995
***************
*** 590,596 ****
  	    fflush(stderr);
  	}
      }
!     if (!jobtab[thisjob].procs)
  	deletejob(jobtab + thisjob);
      else
  	jobtab[thisjob].stat |= STAT_LOCKED;
--- 590,596 ----
  	    fflush(stderr);
  	}
      }
!     if (!jobtab[thisjob].procs || !jobbing)
  	deletejob(jobtab + thisjob);
      else
  	jobtab[thisjob].stat |= STAT_LOCKED;

-- 
Peter Stephenson <pws@xxxxxx>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77330
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.



Messages sorted by: Reverse Date, Date, Thread, Author