Skip to content

Commit e16a73f

Browse files
committed
sh_exec(), sh_ntfork(): rm leftover pre-fork(2) code (re: 7b0e077)
I had missed something while removing the legacy code for ancient systems without fork(2). The SH_NTFORK bit flag was only ever passed to sh_exec() from the version of sh_ntfork() that was compiled on systems without fork(2). With that call removed, this flag is now completely unused. This commit removes the flag and the code that is never executed since that flag is never passed.
1 parent 9b89399 commit e16a73f

File tree

1 file changed

+11
-35
lines changed

1 file changed

+11
-35
lines changed

src/cmd/ksh93/sh/xec.c

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,16 @@
5656
# include <sys/resource.h>
5757
#endif
5858

59-
#if SHOPT_SPAWN && _lib_posix_spawn > 1 && _lib_posix_spawn_file_actions_addtcsetpgrp_np
59+
#undef _use_ntfork_tcpgrp
60+
#if defined(JOBS) && SHOPT_SPAWN && _lib_posix_spawn > 1 && _lib_posix_spawn_file_actions_addtcsetpgrp_np
6061
#define _use_ntfork_tcpgrp 1
6162
#endif
6263

63-
#define SH_NTFORK SH_TIMING
64-
6564
#if _lib_nice
6665
extern int nice(int);
6766
#endif /* _lib_nice */
6867
#if SHOPT_SPAWN
69-
static pid_t sh_ntfork(const Shnode_t*,char*[],int*,int);
68+
static pid_t sh_ntfork(const Shnode_t*,char*[],int*);
7069
#endif /* SHOPT_SPAWN */
7170

7271
static void sh_funct(Namval_t*, int, char*[], struct argnod*,int);
@@ -929,11 +928,6 @@ int sh_exec(register const Shnode_t *t, int flags)
929928
int execflg = (type&sh_state(SH_NOFORK));
930929
int execflg2 = (type&sh_state(SH_FORKED));
931930
int mainloop = (type&sh_state(SH_INTERACTIVE));
932-
#if SHOPT_SPAWN
933-
int ntflag = (type&sh_state(SH_NTFORK));
934-
#else
935-
int ntflag = 0;
936-
#endif
937931
int topfd = sh.topfd;
938932
char *sav=stkfreeze(stkp,0);
939933
char *cp=0, **com=0, *comn;
@@ -1510,8 +1504,7 @@ int sh_exec(register const Shnode_t *t, int flags)
15101504
sh_subfork();
15111505
}
15121506
}
1513-
no_fork = !ntflag
1514-
&& !(type&(FAMP|FPOU))
1507+
no_fork = !(type&(FAMP|FPOU))
15151508
&& !sh.subshell
15161509
&& !(sh.st.trapcom[SIGINT] && *sh.st.trapcom[SIGINT])
15171510
&& !sh.st.trapcom[0]
@@ -1551,7 +1544,7 @@ int sh_exec(register const Shnode_t *t, int flags)
15511544
if(com && !job.jobcontrol)
15521545
#endif /* _use_ntfork_tcpgrp */
15531546
{
1554-
parent = sh_ntfork(t,com,&jobid,ntflag);
1547+
parent = sh_ntfork(t,com,&jobid);
15551548
if(parent<0)
15561549
{
15571550
if(sh.topfd > topfd)
@@ -3411,35 +3404,24 @@ static void sigreset(int mode)
34113404
* Incompatible with job control on interactive shells (job.jobcontrol) if
34123405
* the system does not support posix_spawn_file_actions_addtcsetpgrp_np().
34133406
*/
3414-
static pid_t sh_ntfork(const Shnode_t *t,char *argv[],int *jobid,int flag)
3407+
static pid_t sh_ntfork(const Shnode_t *t,char *argv[],int *jobid)
34153408
{
34163409
static pid_t spawnpid;
3417-
static int savetype;
34183410
struct checkpt *buffp = (struct checkpt*)stkalloc(sh.stk,sizeof(struct checkpt));
3419-
int otype=0, jmpval,jobfork=0;
3411+
int jmpval,jobfork=0;
34203412
volatile int scope=0, sigwasset=0;
34213413
char **arge, *path;
34223414
volatile pid_t grp = 0;
34233415
Pathcomp_t *pp;
34243416
#if _use_ntfork_tcpgrp
34253417
volatile int jobwasset=0;
34263418
#endif /* _use_ntfork_tcpgrp */
3427-
if(flag)
3428-
{
3429-
otype = savetype;
3430-
savetype=0;
3431-
}
34323419
sh_pushcontext(buffp,SH_JMPCMD);
34333420
errorpush(&buffp->err,ERROR_SILENT);
34343421
job_lock(); /* errormsg will unlock */
34353422
jmpval = sigsetjmp(buffp->buff,0);
34363423
if(jmpval == 0)
34373424
{
3438-
if((otype&FINT) && !sh_isstate(SH_MONITOR))
3439-
{
3440-
signal(SIGQUIT,SIG_IGN);
3441-
signal(SIGINT,SIG_IGN);
3442-
}
34433425
spawnpid = -1;
34443426
if(t->com.comio)
34453427
sh_redirect(t->com.comio,0);
@@ -3497,19 +3479,15 @@ static pid_t sh_ntfork(const Shnode_t *t,char *argv[],int *jobid,int flag)
34973479
jobwasset++;
34983480
}
34993481
#endif /* _use_ntfork_tcpgrp */
3500-
#ifdef JOBS
35013482
#if _use_ntfork_tcpgrp
3502-
if(sh_isstate(SH_MONITOR) && (job.jobcontrol || (otype&FAMP)))
3503-
#else
3504-
if(sh_isstate(SH_MONITOR) && (otype&FAMP))
3505-
#endif /* _use_ntfork_tcpgrp */
3483+
if(sh_isstate(SH_MONITOR) && job.jobcontrol)
35063484
{
3507-
if((otype&FAMP) || job.curpgid==0)
3485+
if(job.curpgid==0)
35083486
grp = 1;
35093487
else
35103488
grp = job.curpgid;
35113489
}
3512-
#endif /* JOBS */
3490+
#endif /* _use_ntfork_tcpgrp */
35133491

35143492
sfsync(NIL(Sfio_t*));
35153493
sigreset(0); /* set signals to ignore */
@@ -3604,14 +3582,12 @@ static pid_t sh_ntfork(const Shnode_t *t,char *argv[],int *jobid,int flag)
36043582
siglongjmp(*sh.jmplist,jmpval);
36053583
if(spawnpid>0)
36063584
{
3607-
_sh_fork(spawnpid,otype,jobid);
3585+
_sh_fork(spawnpid,0,jobid);
36083586
job_fork(spawnpid);
36093587
#ifdef JOBS
36103588
if(grp==1)
36113589
job.curpgid = spawnpid;
36123590
#endif /* JOBS */
3613-
if(otype)
3614-
return(0);
36153591
}
36163592
return(spawnpid);
36173593
}

0 commit comments

Comments
 (0)