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

Re: Bug related to stdin/always/jobcontrol



On Sep 22,  9:38am, Bart Schaefer wrote:
} Subject: Re: Bug related to stdin/always/jobcontrol
}
} On Sep 22, 11:59am, Daniel Shahaf wrote:
} }
} } % f() { $EDITOR } 
} } % f
} } <press ^Z in the editor>
} } zsh: suspended  f
} } % fg
} } [1]  + continued  f
} } zsh: suspended (tty output)  f
} 
} Worse that that, signals go to the parent shell:
} 
} torch% kill -9 %1
} Vim: Caught deadly signal HUP
} Vim: Finished.
} zsh: killed     Src/zsh -f

The signal is being sent from here (signals.c):

755                 if (killpg(jobtab[jn->other].gleader, sig) == -1 && errno != ESRCH)

The problem is that jobtab[jn->other].gleader is 0, so killpg kills the
current process.

Obviously the group leader should never be zero, but I haven't figured
out how to track down where it's [not] being set.  Probably this is
related to the shell function not properly attaching to the tty when
foregrounded.

However, in attempting to figure it out, I found some sixteen-year-old
code that is clearly wrong:

diff --git a/Src/exec.c b/Src/exec.c
index d924148..bf97b5c 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1702,7 +1702,7 @@ execpline(Estate state, wordcode slcode, int how, int last1)
 			    jobtab[list_pipe_job].other = newjob;
 			    jobtab[list_pipe_job].stat |= STAT_SUPERJOB;
 			    jn->stat |= STAT_SUBJOB | STAT_NOPRINT;
-			    jn->other = pid;
+			    jn->other = list_pipe_job;
 			    jn->gleader = jobtab[list_pipe_job].gleader;
 			}
 			if ((list_pipe || last1) && hasprocs(list_pipe_job))

jn->other is a job table index, not a process ID.  However, (a) I don't
know if list_pip_job is the right value (although a few lines earlier
list_pipe_pid = pid is assigned, so it would seem to makes sense) and
(b) that this has never caused a wild pointer dereference in all this
time seems to indicate that this code is never actually reached.

I don't have any more time to look at this now; hoping this information
is helpful to PWS if he has a chance to look when he wakes up on Friday.



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