|
56 | 56 | # include <sys/resource.h> |
57 | 57 | #endif |
58 | 58 |
|
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 |
60 | 61 | #define _use_ntfork_tcpgrp 1 |
61 | 62 | #endif |
62 | 63 |
|
63 | | -#define SH_NTFORK SH_TIMING |
64 | | - |
65 | 64 | #if _lib_nice |
66 | 65 | extern int nice(int); |
67 | 66 | #endif /* _lib_nice */ |
68 | 67 | #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*); |
70 | 69 | #endif /* SHOPT_SPAWN */ |
71 | 70 |
|
72 | 71 | 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) |
929 | 928 | int execflg = (type&sh_state(SH_NOFORK)); |
930 | 929 | int execflg2 = (type&sh_state(SH_FORKED)); |
931 | 930 | 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 |
937 | 931 | int topfd = sh.topfd; |
938 | 932 | char *sav=stkfreeze(stkp,0); |
939 | 933 | char *cp=0, **com=0, *comn; |
@@ -1510,8 +1504,7 @@ int sh_exec(register const Shnode_t *t, int flags) |
1510 | 1504 | sh_subfork(); |
1511 | 1505 | } |
1512 | 1506 | } |
1513 | | - no_fork = !ntflag |
1514 | | - && !(type&(FAMP|FPOU)) |
| 1507 | + no_fork = !(type&(FAMP|FPOU)) |
1515 | 1508 | && !sh.subshell |
1516 | 1509 | && !(sh.st.trapcom[SIGINT] && *sh.st.trapcom[SIGINT]) |
1517 | 1510 | && !sh.st.trapcom[0] |
@@ -1551,7 +1544,7 @@ int sh_exec(register const Shnode_t *t, int flags) |
1551 | 1544 | if(com && !job.jobcontrol) |
1552 | 1545 | #endif /* _use_ntfork_tcpgrp */ |
1553 | 1546 | { |
1554 | | - parent = sh_ntfork(t,com,&jobid,ntflag); |
| 1547 | + parent = sh_ntfork(t,com,&jobid); |
1555 | 1548 | if(parent<0) |
1556 | 1549 | { |
1557 | 1550 | if(sh.topfd > topfd) |
@@ -3411,35 +3404,24 @@ static void sigreset(int mode) |
3411 | 3404 | * Incompatible with job control on interactive shells (job.jobcontrol) if |
3412 | 3405 | * the system does not support posix_spawn_file_actions_addtcsetpgrp_np(). |
3413 | 3406 | */ |
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) |
3415 | 3408 | { |
3416 | 3409 | static pid_t spawnpid; |
3417 | | - static int savetype; |
3418 | 3410 | struct checkpt *buffp = (struct checkpt*)stkalloc(sh.stk,sizeof(struct checkpt)); |
3419 | | - int otype=0, jmpval,jobfork=0; |
| 3411 | + int jmpval,jobfork=0; |
3420 | 3412 | volatile int scope=0, sigwasset=0; |
3421 | 3413 | char **arge, *path; |
3422 | 3414 | volatile pid_t grp = 0; |
3423 | 3415 | Pathcomp_t *pp; |
3424 | 3416 | #if _use_ntfork_tcpgrp |
3425 | 3417 | volatile int jobwasset=0; |
3426 | 3418 | #endif /* _use_ntfork_tcpgrp */ |
3427 | | - if(flag) |
3428 | | - { |
3429 | | - otype = savetype; |
3430 | | - savetype=0; |
3431 | | - } |
3432 | 3419 | sh_pushcontext(buffp,SH_JMPCMD); |
3433 | 3420 | errorpush(&buffp->err,ERROR_SILENT); |
3434 | 3421 | job_lock(); /* errormsg will unlock */ |
3435 | 3422 | jmpval = sigsetjmp(buffp->buff,0); |
3436 | 3423 | if(jmpval == 0) |
3437 | 3424 | { |
3438 | | - if((otype&FINT) && !sh_isstate(SH_MONITOR)) |
3439 | | - { |
3440 | | - signal(SIGQUIT,SIG_IGN); |
3441 | | - signal(SIGINT,SIG_IGN); |
3442 | | - } |
3443 | 3425 | spawnpid = -1; |
3444 | 3426 | if(t->com.comio) |
3445 | 3427 | 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) |
3497 | 3479 | jobwasset++; |
3498 | 3480 | } |
3499 | 3481 | #endif /* _use_ntfork_tcpgrp */ |
3500 | | -#ifdef JOBS |
3501 | 3482 | #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) |
3506 | 3484 | { |
3507 | | - if((otype&FAMP) || job.curpgid==0) |
| 3485 | + if(job.curpgid==0) |
3508 | 3486 | grp = 1; |
3509 | 3487 | else |
3510 | 3488 | grp = job.curpgid; |
3511 | 3489 | } |
3512 | | -#endif /* JOBS */ |
| 3490 | +#endif /* _use_ntfork_tcpgrp */ |
3513 | 3491 |
|
3514 | 3492 | sfsync(NIL(Sfio_t*)); |
3515 | 3493 | 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) |
3604 | 3582 | siglongjmp(*sh.jmplist,jmpval); |
3605 | 3583 | if(spawnpid>0) |
3606 | 3584 | { |
3607 | | - _sh_fork(spawnpid,otype,jobid); |
| 3585 | + _sh_fork(spawnpid,0,jobid); |
3608 | 3586 | job_fork(spawnpid); |
3609 | 3587 | #ifdef JOBS |
3610 | 3588 | if(grp==1) |
3611 | 3589 | job.curpgid = spawnpid; |
3612 | 3590 | #endif /* JOBS */ |
3613 | | - if(otype) |
3614 | | - return(0); |
3615 | 3591 | } |
3616 | 3592 | return(spawnpid); |
3617 | 3593 | } |
|
0 commit comments