mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
job_init(): don't call setpgid() if non-interactive (re: 41ebb55a
)
This returns job_init() to a version quite close to the original 93u+ version. Upon further code analysis, really everything after the init_savelist() call is only relevant to interactive shells, so we can just return at that point for non-interactive shells as 93u+ did. All the script-only job control regression tests still pass. Resolves: https://github.com/ksh93/ksh/issues/320
This commit is contained in:
parent
58233b4c50
commit
713260340b
1 changed files with 24 additions and 33 deletions
|
@ -540,9 +540,9 @@ void job_init(int lflag)
|
|||
# endif
|
||||
if(njob_savelist < NJOB_SAVELIST)
|
||||
init_savelist();
|
||||
if(!sh_isoption(SH_INTERACTIVE))
|
||||
return;
|
||||
/* use new line discipline when available */
|
||||
if(sh_isoption(SH_INTERACTIVE))
|
||||
{
|
||||
#ifdef NTTYDISC
|
||||
# ifdef FIOLOOKLD
|
||||
if((job.linedisc = ioctl(JOBTTY, FIOLOOKLD, 0)) <0)
|
||||
|
@ -560,9 +560,7 @@ void job_init(int lflag)
|
|||
}
|
||||
if(job.linedisc==NTTYDISC)
|
||||
job.linedisc = -1;
|
||||
}
|
||||
#endif /* NTTYDISC */
|
||||
|
||||
job.mypgid = getpgrp();
|
||||
/* some systems have job control, but not initialized */
|
||||
if(job.mypgid<=0)
|
||||
|
@ -574,8 +572,6 @@ void job_init(int lflag)
|
|||
#ifndef SIGTSTP
|
||||
setpgid(0,sh.pid);
|
||||
#endif /*SIGTSTP */
|
||||
if(sh_isoption(SH_INTERACTIVE))
|
||||
{
|
||||
if(job.mypgid<0 || !(ttynam=ttyname(JOBTTY)))
|
||||
return;
|
||||
while(close(JOBTTY)<0 && errno==EINTR)
|
||||
|
@ -587,12 +583,11 @@ void job_init(int lflag)
|
|||
#ifdef SIGTSTP
|
||||
tcsetpgrp(JOBTTY,sh.pid);
|
||||
#endif /* SIGTSTP */
|
||||
}
|
||||
job.mypgid = sh.pid;
|
||||
}
|
||||
#ifdef SIGTSTP
|
||||
possible = (setpgid(0,job.mypgid) >= 0) || errno==EPERM;
|
||||
if(sh_isoption(SH_INTERACTIVE) && possible)
|
||||
if(possible)
|
||||
{
|
||||
/* wait until we are in the foreground */
|
||||
while((job.mytgid=tcgetpgrp(JOBTTY)) != job.mypgid)
|
||||
|
@ -611,10 +606,9 @@ void job_init(int lflag)
|
|||
}
|
||||
}
|
||||
#endif /* SIGTTIN */
|
||||
|
||||
#ifdef NTTYDISC
|
||||
/* set the line discipline */
|
||||
if(sh_isoption(SH_INTERACTIVE) && job.linedisc>=0)
|
||||
if(job.linedisc>=0)
|
||||
{
|
||||
int linedisc = NTTYDISC;
|
||||
# ifdef FIOPUSHLD
|
||||
|
@ -635,17 +629,14 @@ void job_init(int lflag)
|
|||
errormsg(SH_DICT,0,e_newtty);
|
||||
else
|
||||
job.linedisc = -1;
|
||||
#endif /* NTTYDISC */
|
||||
}
|
||||
#endif /* NTTYDISC */
|
||||
if(!possible)
|
||||
return;
|
||||
|
||||
#ifdef SIGTSTP
|
||||
/* make sure that we are a process group leader */
|
||||
setpgid(0,sh.pid);
|
||||
job.mypid = sh.pid;
|
||||
if(!sh_isoption(SH_INTERACTIVE))
|
||||
return;
|
||||
# if defined(SA_NOCLDSTOP) || defined(SA_NOCLDWAIT)
|
||||
# if !defined(SA_NOCLDSTOP)
|
||||
# define SA_NOCLDSTOP 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue