🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.bash.bug
Article #310

current job not reset when a job is killed

#310
From: Ray Nickson
Date: Thu, 13 Jul 1989 00:01
61 lines
1935 bytes
ENVIRONMENT: bash 1.01 or 1.02 on an HP300 running MORE/BSD4.3
(although I believe it applies to any system).

SYMPTOM: try the following:
------------------------
bash$ unset auto_resume
bash$ cat
^Z
[1]+ Stopped       cat
bash$ cat
^Z
[2]+ Stopped       cat
bash$ jobs
[1]- Stopped       cat
[2]+ Stopped       cat
bash$ kill -KILL %2
[2]+ Killed        cat     [ aww, poor pussy :-) ]
bash$ jobs
[1]- Stopped       cat
bash$ fg
No such job
bash$
-----------------------

BUG: the shell's notion of previous and current job is not always reset when
the current or previous job dies.

FIX: save them.  I think the delete_job function is the right place to
do it; I haven't properly checked when cleanup_dead_jobs, but the
following patch to version 1.02's jobs.c appears to work in the above
environment.

-rgn
--
nickson@comp.vuw.ac.nz       ...!uunet!vuwcomp!nickson      + 64 4 721000x8142

--------------------cut here--------------------
*** jobs.c.orig	Thu Jul 13 11:28:39 1989
--- jobs.c	Thu Jul 13 11:31:32 1989
***************
*** 272,279 ****
  {
    register JOB *temp = jobs[index];
  
!   jobs[index] = (JOB *)NULL;
  
    free (temp->wd);
    discard_pipeline (temp->pipe);
    if (temp->deferred)
--- 272,282 ----
  {
    register JOB *temp = jobs[index];
  
!   if (index == current_job || index == previous_job)
!     reset_current ();
  
+   jobs[index] = (JOB *)NULL;
+   
    free (temp->wd);
    discard_pipeline (temp->pipe);
    if (temp->deferred)
Technical Details
Message-ID: <8907130002.AA14690@comp.vuw.ac.nz>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!comp.vuw.ac.nz!nickson

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!comp.vuw.ac.nz!nickson
From: nickson@comp.vuw.ac.nz (Ray Nickson)
Newsgroups: gnu.bash.bug
Subject: current job not reset when a job is killed
Message-ID: <8907130002.AA14690@comp.vuw.ac.nz>
Date: 13 Jul 89 00:01:58 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 61