ksh/ksh93-jobs.dif
2012-12-20 14:03:59 +00:00

64 lines
1.8 KiB
Plaintext

--- src/cmd/ksh93/sh/jobs.c
+++ src/cmd/ksh93/sh/jobs.c 2012-12-20 13:33:27.885452491 +0000
@@ -638,12 +638,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)
@@ -660,7 +662,7 @@ void job_init(Shell_t *shp, int lflag)
/* wait until we are in the foreground */
while((job.mytgid=tcgetpgrp(JOBTTY)) != job.mypgid)
{
- if(job.mytgid == -1)
+ if(job.mytgid <= 0)
return;
/* Stop this shell until continued */
signal(SIGTTIN,SIG_DFL);
@@ -833,7 +835,9 @@ static void job_set(register struct proc
if((pw->p_flag&P_STOPPED) || tcgetpgrp(job.fd) == shp->gd->pid)
tcsetpgrp(job.fd,pw->p_fgrp);
/* if job is stopped, resume it in the background */
- job_unstop(pw);
+ if(!shp->forked)
+ job_unstop(pw);
+ shp->forked = 0;
#endif /* SIGTSTP */
}
@@ -1104,7 +1110,7 @@ static struct process *job_bystring(regi
int job_kill(register struct process *pw,register int sig)
{
- Shell_t *shp = pw->p_shp;
+ Shell_t *shp;
register pid_t pid;
register int r;
const char *msg;
@@ -1117,6 +1123,7 @@ int job_kill(register struct process *pw
errno = ECHILD;
if(pw==0)
goto error;
+ shp = pw->p_shp;
pid = pw->p_pid;
#if SHOPT_COSHELL
if(pw->p_cojob)
@@ -2043,6 +2050,7 @@ void job_fork(pid_t parent)
job.in_critical = 0;
break;
default:
+ job_chksave(parent);
jobfork=0;
job_unlock();
break;