Skip to content

Commit 88e8fa6

Browse files
committed
Avoid crash due to broken optimisation in job locking [OpenSUSE]
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
1 parent db72f41 commit 88e8fa6

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎src/cmd/ksh93/sh/jobs.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,12 +530,14 @@ void job_init(Shell_t *shp, int lflag)
530530
/* This should have already been done by rlogin */
531531
register int fd;
532532
register char *ttynam;
533+
int err = errno;
533534
#ifndef SIGTSTP
534535
setpgid(0,shp->gd->pid);
535536
#endif /*SIGTSTP */
536537
if(job.mypgid<0 || !(ttynam=ttyname(JOBTTY)))
537538
return;
538-
close(JOBTTY);
539+
while(close(JOBTTY)<0 && errno==EINTR)
540+
errno = err;
539541
if((fd = open(ttynam,O_RDWR)) <0)
540542
return;
541543
if(fd!=JOBTTY)
@@ -977,9 +979,7 @@ static struct process *job_bystring(register char *ajob)
977979

978980
int job_kill(register struct process *pw,register int sig)
979981
{
980-
if(!pw)
981-
goto error;
982-
Shell_t *shp = pw->p_shp;
982+
Shell_t *shp;
983983
register pid_t pid;
984984
register int r;
985985
const char *msg;
@@ -990,6 +990,9 @@ int job_kill(register struct process *pw,register int sig)
990990
#endif /* SIGTSTP */
991991
job_lock();
992992
errno = ECHILD;
993+
if(pw==0)
994+
goto error;
995+
shp = pw->p_shp;
993996
pid = pw->p_pid;
994997
if(by_number)
995998
{

0 commit comments

Comments
 (0)