Skip to content

Commit

Permalink
Avoid crash due to broken optimisation in job locking [OpenSUSE]
Browse files Browse the repository at this point in the history
This applies ksh93-jobs.dif from OpenSUSE. Source:
https://build.opensuse.org/package/show/openSUSE:Leap:42.3:Update/ksh

src/cmd/ksh93/sh/jobs.c:
- jog_init(): Save errno in case close(JOBTTY) fails. If cause of
  failure was interruption by a signal (EINTR), repeat close.
- job_kill(): Replace Red Hat fix for #35 with nicer OpenSUSE fix
  that doesn't add a goto before declaring variables. Re: ff358f3
  • Loading branch information
McDutchie committed Jul 22, 2020
1 parent db72f41 commit 88e8fa6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/cmd/ksh93/sh/jobs.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,12 +530,14 @@ void job_init(Shell_t *shp, int lflag)
/* This should have already been done by rlogin */
register int fd;
register char *ttynam;
int err = errno;
#ifndef SIGTSTP
setpgid(0,shp->gd->pid);
#endif /*SIGTSTP */
if(job.mypgid<0 || !(ttynam=ttyname(JOBTTY)))
return;
close(JOBTTY);
while(close(JOBTTY)<0 && errno==EINTR)
errno = err;
if((fd = open(ttynam,O_RDWR)) <0)
return;
if(fd!=JOBTTY)
Expand Down Expand Up @@ -977,9 +979,7 @@ static struct process *job_bystring(register char *ajob)

int job_kill(register struct process *pw,register int sig)
{
if(!pw)
goto error;
Shell_t *shp = pw->p_shp;
Shell_t *shp;
register pid_t pid;
register int r;
const char *msg;
Expand All @@ -990,6 +990,9 @@ int job_kill(register struct process *pw,register int sig)
#endif /* SIGTSTP */
job_lock();
errno = ECHILD;
if(pw==0)
goto error;
shp = pw->p_shp;
pid = pw->p_pid;
if(by_number)
{
Expand Down

0 comments on commit 88e8fa6

Please sign in to comment.