aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2025-08-09 17:17:48 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2025-08-09 17:17:48 +0200
commit9f490785e00bd5c4deee09d9fee3badd8d70ada4 (patch)
tree2d2c97a581251755b76fb691d7e0a378d67ba851 /shell
parent53b3854e8141f4fc5fad10f180fc4fac2feee954 (diff)
downloadbusybox-w32-9f490785e00bd5c4deee09d9fee3badd8d70ada4.tar.gz
busybox-w32-9f490785e00bd5c4deee09d9fee3badd8d70ada4.tar.bz2
busybox-w32-9f490785e00bd5c4deee09d9fee3badd8d70ada4.zip
ash: rename got_sigchld, doing_jobctl, and INT_ON/OFF to match dash
Comparing code with dash is more difficult with these differences. (We didn't know back then that dash will be revived...) Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c300
1 files changed, 150 insertions, 150 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 3e393715b..81b4a8951 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -431,7 +431,7 @@ struct globals_misc {
431 * but we do read it async. 431 * but we do read it async.
432 */ 432 */
433 volatile /*sig_atomic_t*/ smallint pending_int; /* 1 = got SIGINT */ 433 volatile /*sig_atomic_t*/ smallint pending_int; /* 1 = got SIGINT */
434 volatile /*sig_atomic_t*/ smallint got_sigchld; /* 1 = got SIGCHLD */ 434 volatile /*sig_atomic_t*/ smallint gotsigchld; /* 1 = got SIGCHLD */
435 volatile /*sig_atomic_t*/ smallint pending_sig; /* last pending signal */ 435 volatile /*sig_atomic_t*/ smallint pending_sig; /* last pending signal */
436 smallint exception_type; /* kind of exception: */ 436 smallint exception_type; /* kind of exception: */
437#define EXINT 0 /* SIGINT received */ 437#define EXINT 0 /* SIGINT received */
@@ -518,7 +518,7 @@ extern struct globals_misc *BB_GLOBAL_CONST ash_ptr_to_globals_misc;
518#define exception_type (G_misc.exception_type ) 518#define exception_type (G_misc.exception_type )
519#define suppress_int (G_misc.suppress_int ) 519#define suppress_int (G_misc.suppress_int )
520#define pending_int (G_misc.pending_int ) 520#define pending_int (G_misc.pending_int )
521#define got_sigchld (G_misc.got_sigchld ) 521#define gotsigchld (G_misc.gotsigchld )
522#define pending_sig (G_misc.pending_sig ) 522#define pending_sig (G_misc.pending_sig )
523#define nullstr (G_misc.nullstr ) 523#define nullstr (G_misc.nullstr )
524#define optlist (G_misc.optlist ) 524#define optlist (G_misc.optlist )
@@ -653,13 +653,13 @@ static void exitshell(void) NORETURN;
653 * more fun than worrying about efficiency and portability. :-)) 653 * more fun than worrying about efficiency and portability. :-))
654 */ 654 */
655#if DEBUG_INTONOFF 655#if DEBUG_INTONOFF
656# define INT_OFF do { \ 656# define INTOFF do { \
657 TRACE(("%s:%d INT_OFF(%d)\n", __func__, __LINE__, suppress_int)); \ 657 TRACE(("%s:%d INTOFF(%d)\n", __func__, __LINE__, suppress_int)); \
658 suppress_int++; \ 658 suppress_int++; \
659 barrier(); \ 659 barrier(); \
660} while (0) 660} while (0)
661#else 661#else
662# define INT_OFF do { \ 662# define INTOFF do { \
663 suppress_int++; \ 663 suppress_int++; \
664 barrier(); \ 664 barrier(); \
665} while (0) 665} while (0)
@@ -678,7 +678,7 @@ raise_exception(int e)
678 if (exception_handler == NULL) 678 if (exception_handler == NULL)
679 abort(); 679 abort();
680#endif 680#endif
681 INT_OFF; 681 INTOFF;
682 exception_type = e; 682 exception_type = e;
683 longjmp(exception_handler->loc, 1); 683 longjmp(exception_handler->loc, 1);
684} 684}
@@ -693,7 +693,7 @@ raise_exception(int e)
693 * Called when a SIGINT is received. (If the user specifies 693 * Called when a SIGINT is received. (If the user specifies
694 * that SIGINT is to be trapped or ignored using the trap builtin, then 694 * that SIGINT is to be trapped or ignored using the trap builtin, then
695 * this routine is not called.) suppress_int is nonzero when interrupts 695 * this routine is not called.) suppress_int is nonzero when interrupts
696 * are held using the INT_OFF macro. (The test for iflag is just 696 * are held using the INTOFF macro. (The test for iflag is just
697 * defensive programming.) 697 * defensive programming.)
698 */ 698 */
699static void raise_interrupt(void) NORETURN; 699static void raise_interrupt(void) NORETURN;
@@ -732,12 +732,12 @@ int_on(void)
732 barrier(); 732 barrier();
733} 733}
734#if DEBUG_INTONOFF 734#if DEBUG_INTONOFF
735# define INT_ON do { \ 735# define INTON do { \
736 TRACE(("%s:%d INT_ON(%d)\n", __func__, __LINE__, suppress_int-1)); \ 736 TRACE(("%s:%d INTON(%d)\n", __func__, __LINE__, suppress_int-1)); \
737 int_on(); \ 737 int_on(); \
738} while (0) 738} while (0)
739#else 739#else
740# define INT_ON int_on() 740# define INTON int_on()
741#endif 741#endif
742static IF_NOT_ASH_OPTIMIZE_FOR_SIZE(inline) void 742static IF_NOT_ASH_OPTIMIZE_FOR_SIZE(inline) void
743force_int_on(void) 743force_int_on(void)
@@ -748,7 +748,7 @@ force_int_on(void)
748 raise_interrupt(); /* does not return */ 748 raise_interrupt(); /* does not return */
749 barrier(); 749 barrier();
750} 750}
751#define FORCE_INT_ON force_int_on() 751#define FORCEINTON force_int_on()
752 752
753#define SAVE_INT(v) ((v) = suppress_int) 753#define SAVE_INT(v) ((v) = suppress_int)
754 754
@@ -766,27 +766,27 @@ force_int_on(void)
766static void 766static void
767outstr(const char *p, FILE *file) 767outstr(const char *p, FILE *file)
768{ 768{
769 INT_OFF; 769 INTOFF;
770 fputs(p, file); 770 fputs(p, file);
771 INT_ON; 771 INTON;
772} 772}
773 773
774static void 774static void
775flush_stdout_stderr(void) 775flush_stdout_stderr(void)
776{ 776{
777 INT_OFF; 777 INTOFF;
778 fflush_all(); 778 fflush_all();
779 INT_ON; 779 INTON;
780} 780}
781 781
782/* Was called outcslow(c,FILE*), but c was always '\n' */ 782/* Was called outcslow(c,FILE*), but c was always '\n' */
783static void 783static void
784newline_and_flush(FILE *dest) 784newline_and_flush(FILE *dest)
785{ 785{
786 INT_OFF; 786 INTOFF;
787 putc('\n', dest); 787 putc('\n', dest);
788 fflush(dest); 788 fflush(dest);
789 INT_ON; 789 INTON;
790} 790}
791 791
792static int out1fmt(const char *, ...) __attribute__((__format__(__printf__,1,2))); 792static int out1fmt(const char *, ...) __attribute__((__format__(__printf__,1,2)));
@@ -796,11 +796,11 @@ out1fmt(const char *fmt, ...)
796 va_list ap; 796 va_list ap;
797 int r; 797 int r;
798 798
799 INT_OFF; 799 INTOFF;
800 va_start(ap, fmt); 800 va_start(ap, fmt);
801 r = vprintf(fmt, ap); 801 r = vprintf(fmt, ap);
802 va_end(ap); 802 va_end(ap);
803 INT_ON; 803 INTON;
804 return r; 804 return r;
805} 805}
806 806
@@ -811,11 +811,11 @@ fmtstr(char *outbuf, size_t length, const char *fmt, ...)
811 va_list ap; 811 va_list ap;
812 int ret; 812 int ret;
813 813
814 INT_OFF; 814 INTOFF;
815 va_start(ap, fmt); 815 va_start(ap, fmt);
816 ret = vsnprintf(outbuf, length, fmt, ap); 816 ret = vsnprintf(outbuf, length, fmt, ap);
817 va_end(ap); 817 va_end(ap);
818 INT_ON; 818 INTON;
819 return ret > (int)length ? length : ret; 819 return ret > (int)length ? length : ret;
820} 820}
821 821
@@ -1670,14 +1670,14 @@ stalloc(size_t nbytes)
1670 len = sizeof(struct stack_block) - MINSIZE + blocksize; 1670 len = sizeof(struct stack_block) - MINSIZE + blocksize;
1671 if (len < blocksize) 1671 if (len < blocksize)
1672 ash_msg_and_raise_error(bb_msg_memory_exhausted); 1672 ash_msg_and_raise_error(bb_msg_memory_exhausted);
1673 INT_OFF; 1673 INTOFF;
1674 sp = ckmalloc(len); 1674 sp = ckmalloc(len);
1675 sp->prev = g_stackp; 1675 sp->prev = g_stackp;
1676 g_stacknxt = sp->space; 1676 g_stacknxt = sp->space;
1677 g_stacknleft = blocksize; 1677 g_stacknleft = blocksize;
1678 sstrend = g_stacknxt + blocksize; 1678 sstrend = g_stacknxt + blocksize;
1679 g_stackp = sp; 1679 g_stackp = sp;
1680 INT_ON; 1680 INTON;
1681 } 1681 }
1682 p = g_stacknxt; 1682 p = g_stacknxt;
1683 g_stacknxt += aligned; 1683 g_stacknxt += aligned;
@@ -1743,7 +1743,7 @@ popstackmark(struct stackmark *mark)
1743 if (!mark->stackp) 1743 if (!mark->stackp)
1744 return; 1744 return;
1745 1745
1746 INT_OFF; 1746 INTOFF;
1747 while (g_stackp != mark->stackp) { 1747 while (g_stackp != mark->stackp) {
1748 sp = g_stackp; 1748 sp = g_stackp;
1749 g_stackp = sp->prev; 1749 g_stackp = sp->prev;
@@ -1752,7 +1752,7 @@ popstackmark(struct stackmark *mark)
1752 g_stacknxt = mark->stacknxt; 1752 g_stacknxt = mark->stacknxt;
1753 g_stacknleft = mark->stacknleft; 1753 g_stacknleft = mark->stacknleft;
1754 sstrend = mark->stacknxt + mark->stacknleft; 1754 sstrend = mark->stacknxt + mark->stacknleft;
1755 INT_ON; 1755 INTON;
1756} 1756}
1757 1757
1758/* 1758/*
@@ -1781,7 +1781,7 @@ growstackblock(size_t min)
1781 struct stack_block *prevstackp; 1781 struct stack_block *prevstackp;
1782 size_t grosslen; 1782 size_t grosslen;
1783 1783
1784 INT_OFF; 1784 INTOFF;
1785 sp = g_stackp; 1785 sp = g_stackp;
1786 prevstackp = sp->prev; 1786 prevstackp = sp->prev;
1787 grosslen = newlen + sizeof(struct stack_block) - MINSIZE; 1787 grosslen = newlen + sizeof(struct stack_block) - MINSIZE;
@@ -1791,7 +1791,7 @@ growstackblock(size_t min)
1791 g_stacknxt = sp->space; 1791 g_stacknxt = sp->space;
1792 g_stacknleft = newlen; 1792 g_stacknleft = newlen;
1793 sstrend = sp->space + newlen; 1793 sstrend = sp->space + newlen;
1794 INT_ON; 1794 INTON;
1795 } else { 1795 } else {
1796 char *oldspace = g_stacknxt; 1796 char *oldspace = g_stacknxt;
1797 size_t oldlen = g_stacknleft; 1797 size_t oldlen = g_stacknleft;
@@ -2524,7 +2524,7 @@ setvar(const char *name, const char *val, int flags)
2524 vallen = strlen(val); 2524 vallen = strlen(val);
2525 } 2525 }
2526 2526
2527 INT_OFF; 2527 INTOFF;
2528 nameeq = ckzalloc(namelen + vallen + 2); 2528 nameeq = ckzalloc(namelen + vallen + 2);
2529 p = mempcpy(nameeq, name, namelen); 2529 p = mempcpy(nameeq, name, namelen);
2530 if (val) { 2530 if (val) {
@@ -2532,7 +2532,7 @@ setvar(const char *name, const char *val, int flags)
2532 strcpy(p, val); 2532 strcpy(p, val);
2533 } 2533 }
2534 vp = setvareq(nameeq, flags | VNOSAVE); 2534 vp = setvareq(nameeq, flags | VNOSAVE);
2535 INT_ON; 2535 INTON;
2536 2536
2537 return vp; 2537 return vp;
2538} 2538}
@@ -2891,7 +2891,7 @@ setpwd(const char *val, int setold)
2891 if (setold) { 2891 if (setold) {
2892 setvar("OLDPWD", oldcur, VEXPORT); 2892 setvar("OLDPWD", oldcur, VEXPORT);
2893 } 2893 }
2894 INT_OFF; 2894 INTOFF;
2895 if (physdir != nullstr) { 2895 if (physdir != nullstr) {
2896 if (physdir != oldcur) 2896 if (physdir != oldcur)
2897 free(physdir); 2897 free(physdir);
@@ -2908,7 +2908,7 @@ setpwd(const char *val, int setold)
2908 free(oldcur); 2908 free(oldcur);
2909 } 2909 }
2910 curdir = dir; 2910 curdir = dir;
2911 INT_ON; 2911 INTON;
2912 setvar("PWD", dir, VEXPORT); 2912 setvar("PWD", dir, VEXPORT);
2913} 2913}
2914 2914
@@ -2926,7 +2926,7 @@ docd(const char *dest, int flags)
2926 2926
2927 TRACE(("docd(\"%s\", %d) called\n", dest, flags)); 2927 TRACE(("docd(\"%s\", %d) called\n", dest, flags));
2928 2928
2929 INT_OFF; 2929 INTOFF;
2930 if (!(flags & CD_PHYSICAL)) { 2930 if (!(flags & CD_PHYSICAL)) {
2931 dir = updatepwd(dest); 2931 dir = updatepwd(dest);
2932 if (dir) 2932 if (dir)
@@ -2938,7 +2938,7 @@ docd(const char *dest, int flags)
2938 setpwd(dir, 1); 2938 setpwd(dir, 1);
2939 hashcd(); 2939 hashcd();
2940 out: 2940 out:
2941 INT_ON; 2941 INTON;
2942 return err; 2942 return err;
2943} 2943}
2944 2944
@@ -3499,7 +3499,7 @@ setalias(const char *name, const char *val)
3499 3499
3500 app = __lookupalias(name); 3500 app = __lookupalias(name);
3501 ap = *app; 3501 ap = *app;
3502 INT_OFF; 3502 INTOFF;
3503 if (ap) { 3503 if (ap) {
3504 if (!(ap->flag & ALIASINUSE)) { 3504 if (!(ap->flag & ALIASINUSE)) {
3505 free(ap->val); 3505 free(ap->val);
@@ -3515,7 +3515,7 @@ setalias(const char *name, const char *val)
3515 /*ap->next = NULL;*/ 3515 /*ap->next = NULL;*/
3516 *app = ap; 3516 *app = ap;
3517 } 3517 }
3518 INT_ON; 3518 INTON;
3519} 3519}
3520 3520
3521static int 3521static int
@@ -3526,9 +3526,9 @@ unalias(const char *name)
3526 app = __lookupalias(name); 3526 app = __lookupalias(name);
3527 3527
3528 if (*app) { 3528 if (*app) {
3529 INT_OFF; 3529 INTOFF;
3530 *app = freealias(*app); 3530 *app = freealias(*app);
3531 INT_ON; 3531 INTON;
3532 return 0; 3532 return 0;
3533 } 3533 }
3534 3534
@@ -3541,7 +3541,7 @@ rmaliases(void)
3541 struct alias *ap, **app; 3541 struct alias *ap, **app;
3542 int i; 3542 int i;
3543 3543
3544 INT_OFF; 3544 INTOFF;
3545 for (i = 0; i < ATABSIZE; i++) { 3545 for (i = 0; i < ATABSIZE; i++) {
3546 app = &atab[i]; 3546 app = &atab[i];
3547 for (ap = *app; ap; ap = *app) { 3547 for (ap = *app; ap; ap = *app) {
@@ -3551,7 +3551,7 @@ rmaliases(void)
3551 } 3551 }
3552 } 3552 }
3553 } 3553 }
3554 INT_ON; 3554 INTON;
3555} 3555}
3556 3556
3557static void 3557static void
@@ -3670,10 +3670,10 @@ static int forkshell(struct job *, union node *, int);
3670static int waitforjob(struct job *); 3670static int waitforjob(struct job *);
3671 3671
3672#if !JOBS 3672#if !JOBS
3673enum { doing_jobctl = 0 }; 3673enum { jobctl = 0 };
3674#define setjobctl(on) do {} while (0) 3674#define setjobctl(on) do {} while (0)
3675#else 3675#else
3676static smallint doing_jobctl; //references:8 3676static smallint jobctl; //references:8
3677static void setjobctl(int); 3677static void setjobctl(int);
3678#endif 3678#endif
3679 3679
@@ -3698,7 +3698,7 @@ static void
3698signal_handler(int signo) 3698signal_handler(int signo)
3699{ 3699{
3700 if (signo == SIGCHLD) { 3700 if (signo == SIGCHLD) {
3701 got_sigchld = 1; 3701 gotsigchld = 1;
3702 if (!trap[SIGCHLD]) 3702 if (!trap[SIGCHLD])
3703 return; 3703 return;
3704 } 3704 }
@@ -4058,7 +4058,7 @@ freejob(struct job *jp)
4058 struct procstat *ps; 4058 struct procstat *ps;
4059 int i; 4059 int i;
4060 4060
4061 INT_OFF; 4061 INTOFF;
4062 for (i = jp->nprocs, ps = jp->ps; --i >= 0; ps++) { 4062 for (i = jp->nprocs, ps = jp->ps; --i >= 0; ps++) {
4063 if (ps->ps_cmd != nullstr) 4063 if (ps->ps_cmd != nullstr)
4064 free(ps->ps_cmd); 4064 free(ps->ps_cmd);
@@ -4067,7 +4067,7 @@ freejob(struct job *jp)
4067 free(jp->ps); 4067 free(jp->ps);
4068 jp->used = 0; 4068 jp->used = 0;
4069 set_curjob(jp, CUR_DELETE); 4069 set_curjob(jp, CUR_DELETE);
4070 INT_ON; 4070 INTON;
4071} 4071}
4072 4072
4073#if JOBS 4073#if JOBS
@@ -4093,7 +4093,7 @@ setjobctl(int on)
4093 int fd; 4093 int fd;
4094 int pgrp; 4094 int pgrp;
4095 4095
4096 if (on == doing_jobctl || rootshell == 0) 4096 if (on == jobctl || rootshell == 0)
4097 return; 4097 return;
4098 if (on) { 4098 if (on) {
4099 int ofd; 4099 int ofd;
@@ -4153,7 +4153,7 @@ setjobctl(int on)
4153 fd = -1; 4153 fd = -1;
4154 } 4154 }
4155 ttyfd = fd; 4155 ttyfd = fd;
4156 doing_jobctl = on; 4156 jobctl = on;
4157} 4157}
4158 4158
4159static int FAST_FUNC 4159static int FAST_FUNC
@@ -4232,7 +4232,7 @@ restartjob(struct job *jp, int mode)
4232 int status; 4232 int status;
4233 pid_t pgid; 4233 pid_t pgid;
4234 4234
4235 INT_OFF; 4235 INTOFF;
4236 if (jp->state == JOBDONE) 4236 if (jp->state == JOBDONE)
4237 goto out; 4237 goto out;
4238 jp->state = JOBRUNNING; 4238 jp->state = JOBRUNNING;
@@ -4252,7 +4252,7 @@ restartjob(struct job *jp, int mode)
4252 } while (--i); 4252 } while (--i);
4253 out: 4253 out:
4254 status = (mode == FORK_FG) ? waitforjob(jp) : 0; 4254 status = (mode == FORK_FG) ? waitforjob(jp) : 0;
4255 INT_ON; 4255 INTON;
4256 return status; 4256 return status;
4257} 4257}
4258 4258
@@ -4329,12 +4329,12 @@ waitproc(int block, int *status)
4329 int err; 4329 int err;
4330 4330
4331#if JOBS 4331#if JOBS
4332 if (doing_jobctl) 4332 if (jobctl)
4333 flags |= WUNTRACED; 4333 flags |= WUNTRACED;
4334#endif 4334#endif
4335 4335
4336 do { 4336 do {
4337 got_sigchld = 0; 4337 gotsigchld = 0;
4338 do 4338 do
4339 err = waitpid(-1, status, flags); 4339 err = waitpid(-1, status, flags);
4340 while (err < 0 && errno == EINTR); 4340 while (err < 0 && errno == EINTR);
@@ -4344,14 +4344,14 @@ waitproc(int block, int *status)
4344 4344
4345 sigfillset(&oldmask); 4345 sigfillset(&oldmask);
4346 sigprocmask2(SIG_SETMASK, &oldmask); /* mask is updated */ 4346 sigprocmask2(SIG_SETMASK, &oldmask); /* mask is updated */
4347 while (!got_sigchld && !pending_sig) 4347 while (!gotsigchld && !pending_sig)
4348 sigsuspend(&oldmask); 4348 sigsuspend(&oldmask);
4349 sigprocmask(SIG_SETMASK, &oldmask, NULL); 4349 sigprocmask(SIG_SETMASK, &oldmask, NULL);
4350 //simpler, but unsafe: a signal can set pending_sig after check, but before pause(): 4350 //simpler, but unsafe: a signal can set pending_sig after check, but before pause():
4351 //while (!got_sigchld && !pending_sig) 4351 //while (!gotsigchld && !pending_sig)
4352 // pause(); 4352 // pause();
4353 4353
4354 } while (got_sigchld); 4354 } while (gotsigchld);
4355 4355
4356 return err; 4356 return err;
4357} 4357}
@@ -4370,25 +4370,25 @@ waitone(int block, struct job *job)
4370 4370
4371 TRACE(("dowait(0x%x) called\n", block)); 4371 TRACE(("dowait(0x%x) called\n", block));
4372 4372
4373 /* It's wrong to call waitpid() outside of INT_OFF region: 4373 /* It's wrong to call waitpid() outside of INTOFF region:
4374 * signal can arrive just after syscall return and handler can 4374 * signal can arrive just after syscall return and handler can
4375 * longjmp away, losing stop/exit notification processing. 4375 * longjmp away, losing stop/exit notification processing.
4376 * Thus, for "jobs" builtin, and for waiting for a fg job, 4376 * Thus, for "jobs" builtin, and for waiting for a fg job,
4377 * we call waitpid() (blocking or non-blocking) inside INT_OFF. 4377 * we call waitpid() (blocking or non-blocking) inside INTOFF.
4378 * 4378 *
4379 * However, for "wait" builtin it is wrong to simply call waitpid() 4379 * However, for "wait" builtin it is wrong to simply call waitpid()
4380 * in INT_OFF region: "wait" needs to wait for any running job 4380 * in INTOFF region: "wait" needs to wait for any running job
4381 * to change state, but should exit on any trap too. 4381 * to change state, but should exit on any trap too.
4382 * In INT_OFF region, a signal just before syscall entry can set 4382 * In INTOFF region, a signal just before syscall entry can set
4383 * pending_sig variables, but we can't check them, and we would 4383 * pending_sig variables, but we can't check them, and we would
4384 * either enter a sleeping waitpid() (BUG), or need to busy-loop. 4384 * either enter a sleeping waitpid() (BUG), or need to busy-loop.
4385 * 4385 *
4386 * Because of this, we run inside INT_OFF, but use a special routine 4386 * Because of this, we run inside INTOFF, but use a special routine
4387 * which combines waitpid() and sigsuspend(). 4387 * which combines waitpid() and sigsuspend().
4388 * This is the reason why we need to have a handler for SIGCHLD: 4388 * This is the reason why we need to have a handler for SIGCHLD:
4389 * SIG_DFL handler does not wake sigsuspend(). 4389 * SIG_DFL handler does not wake sigsuspend().
4390 */ 4390 */
4391 INT_OFF; 4391 INTOFF;
4392 pid = waitproc(block, &status); 4392 pid = waitproc(block, &status);
4393 TRACE(("wait returns pid %d, status=%d\n", pid, status)); 4393 TRACE(("wait returns pid %d, status=%d\n", pid, status));
4394 if (pid <= 0) 4394 if (pid <= 0)
@@ -4446,7 +4446,7 @@ waitone(int block, struct job *job)
4446 } 4446 }
4447 /* The process wasn't found in job list */ 4447 /* The process wasn't found in job list */
4448 out: 4448 out:
4449 INT_ON; 4449 INTON;
4450 4450
4451#if BASH_WAIT_N 4451#if BASH_WAIT_N
4452 if (want_jobexitstatus) { 4452 if (want_jobexitstatus) {
@@ -4472,7 +4472,7 @@ waitone(int block, struct job *job)
4472static int 4472static int
4473dowait(int block, struct job *jp) 4473dowait(int block, struct job *jp)
4474{ 4474{
4475 smallint gotchld = *(volatile smallint *)&got_sigchld; 4475 smallint gotchld = *(volatile smallint *)&gotsigchld;
4476 int rpid; 4476 int rpid;
4477 int pid; 4477 int pid;
4478 4478
@@ -4817,7 +4817,7 @@ makejob(int nprocs)
4817 if (jp->state != JOBDONE || !jp->waited) 4817 if (jp->state != JOBDONE || !jp->waited)
4818 continue; 4818 continue;
4819#if JOBS 4819#if JOBS
4820 if (doing_jobctl) 4820 if (jobctl)
4821 continue; 4821 continue;
4822#endif 4822#endif
4823 freejob(jp); 4823 freejob(jp);
@@ -4826,8 +4826,8 @@ makejob(int nprocs)
4826 memset(jp, 0, sizeof(*jp)); 4826 memset(jp, 0, sizeof(*jp));
4827#if JOBS 4827#if JOBS
4828 /* jp->jobctl is a bitfield. 4828 /* jp->jobctl is a bitfield.
4829 * "jp->jobctl |= doing_jobctl" likely to give awful code */ 4829 * "jp->jobctl |= jobctl" likely to give awful code */
4830 if (doing_jobctl) 4830 if (jobctl)
4831 jp->jobctl = 1; 4831 jp->jobctl = 1;
4832#endif 4832#endif
4833 jp->prev_job = curjob; 4833 jp->prev_job = curjob;
@@ -5164,7 +5164,7 @@ clear_traps(void)
5164{ 5164{
5165 char **tp; 5165 char **tp;
5166 5166
5167 INT_OFF; 5167 INTOFF;
5168 for (tp = trap; tp <= &trap[NTRAP_LAST]; tp++) { 5168 for (tp = trap; tp <= &trap[NTRAP_LAST]; tp++) {
5169 if (*tp && **tp) { /* trap not NULL or "" (SIG_IGN) */ 5169 if (*tp && **tp) { /* trap not NULL or "" (SIG_IGN) */
5170 if (trap_ptr == trap) 5170 if (trap_ptr == trap)
@@ -5176,7 +5176,7 @@ clear_traps(void)
5176 } 5176 }
5177 } 5177 }
5178 may_have_traps = 0; 5178 may_have_traps = 0;
5179 INT_ON; 5179 INTON;
5180} 5180}
5181 5181
5182/* Lives far away from here, needed for forkchild */ 5182/* Lives far away from here, needed for forkchild */
@@ -5247,7 +5247,7 @@ forkchild(struct job *jp, union node *n, int mode)
5247 clear_traps(); 5247 clear_traps();
5248#if JOBS 5248#if JOBS
5249 /* do job control only in root shell */ 5249 /* do job control only in root shell */
5250 doing_jobctl = 0; 5250 jobctl = 0;
5251 if (mode != FORK_NOJOB && jp->jobctl && oldlvl == 0) { 5251 if (mode != FORK_NOJOB && jp->jobctl && oldlvl == 0) {
5252 pid_t pgrp; 5252 pid_t pgrp;
5253 5253
@@ -5338,7 +5338,7 @@ forkparent(struct job *jp, union node *n, int mode, pid_t pid)
5338 ps->ps_status = -1; 5338 ps->ps_status = -1;
5339 ps->ps_cmd = nullstr; 5339 ps->ps_cmd = nullstr;
5340#if JOBS 5340#if JOBS
5341 if (doing_jobctl && n) 5341 if (jobctl && n)
5342 ps->ps_cmd = commandtext(n); 5342 ps->ps_cmd = commandtext(n);
5343#endif 5343#endif
5344 } 5344 }
@@ -5853,7 +5853,7 @@ redirect(union node *redir, int flags)
5853 return; 5853 return;
5854 5854
5855 sv = NULL; 5855 sv = NULL;
5856 INT_OFF; 5856 INTOFF;
5857 if (flags & REDIR_PUSH) 5857 if (flags & REDIR_PUSH)
5858 sv = redirlist; 5858 sv = redirlist;
5859 do { 5859 do {
@@ -5918,7 +5918,7 @@ redirect(union node *redir, int flags)
5918#endif 5918#endif
5919 } 5919 }
5920 } while ((redir = redir->nfile.next) != NULL); 5920 } while ((redir = redir->nfile.next) != NULL);
5921 INT_ON; 5921 INTON;
5922 5922
5923//dash:#define REDIR_SAVEFD2 03 /* set preverrout */ 5923//dash:#define REDIR_SAVEFD2 03 /* set preverrout */
5924#define REDIR_SAVEFD2 0 5924#define REDIR_SAVEFD2 0
@@ -6006,7 +6006,7 @@ popredir(int drop)
6006 6006
6007 if (redirlist == NULL) 6007 if (redirlist == NULL)
6008 return; 6008 return;
6009 INT_OFF; 6009 INTOFF;
6010 rp = redirlist; 6010 rp = redirlist;
6011 for (i = 0; i < rp->pair_count; i++) { 6011 for (i = 0; i < rp->pair_count; i++) {
6012 int fd = rp->two_fd[i].orig_fd; 6012 int fd = rp->two_fd[i].orig_fd;
@@ -6026,7 +6026,7 @@ popredir(int drop)
6026 } 6026 }
6027 redirlist = rp->next; 6027 redirlist = rp->next;
6028 free(rp); 6028 free(rp);
6029 INT_ON; 6029 INTON;
6030} 6030}
6031 6031
6032static void 6032static void
@@ -6053,11 +6053,11 @@ ash_arith(const char *s)
6053 math_state.setvar = setvar0; 6053 math_state.setvar = setvar0;
6054 //math_state.endofname = endofname; 6054 //math_state.endofname = endofname;
6055 6055
6056 INT_OFF; 6056 INTOFF;
6057 result = arith(&math_state, s); 6057 result = arith(&math_state, s);
6058 if (math_state.errmsg) 6058 if (math_state.errmsg)
6059 ash_msg_and_raise_error(math_state.errmsg); 6059 ash_msg_and_raise_error(math_state.errmsg);
6060 INT_ON; 6060 INTON;
6061 6061
6062 return result; 6062 return result;
6063} 6063}
@@ -6249,7 +6249,7 @@ ifsfree(void)
6249 if (!p) 6249 if (!p)
6250 goto out; 6250 goto out;
6251 6251
6252 INT_OFF; 6252 INTOFF;
6253 do { 6253 do {
6254 struct ifsregion *ifsp; 6254 struct ifsregion *ifsp;
6255 ifsp = p->next; 6255 ifsp = p->next;
@@ -6257,7 +6257,7 @@ ifsfree(void)
6257 p = ifsp; 6257 p = ifsp;
6258 } while (p); 6258 } while (p);
6259 ifsfirst.next = NULL; 6259 ifsfirst.next = NULL;
6260 INT_ON; 6260 INTON;
6261 out: 6261 out:
6262 ifslastp = NULL; 6262 ifslastp = NULL;
6263} 6263}
@@ -6472,11 +6472,11 @@ recordregion(int start, int end, int nulonly)
6472 if (ifslastp == NULL) { 6472 if (ifslastp == NULL) {
6473 ifsp = &ifsfirst; 6473 ifsp = &ifsfirst;
6474 } else { 6474 } else {
6475 INT_OFF; 6475 INTOFF;
6476 ifsp = ckzalloc(sizeof(*ifsp)); 6476 ifsp = ckzalloc(sizeof(*ifsp));
6477 /*ifsp->next = NULL; - ckzalloc did it */ 6477 /*ifsp->next = NULL; - ckzalloc did it */
6478 ifslastp->next = ifsp; 6478 ifslastp->next = ifsp;
6479 INT_ON; 6479 INTON;
6480 } 6480 }
6481 ifslastp = ifsp; 6481 ifslastp = ifsp;
6482 ifslastp->begoff = start; 6482 ifslastp->begoff = start;
@@ -6493,11 +6493,11 @@ removerecordregions(int endoff)
6493 if (ifsfirst.endoff > endoff) { 6493 if (ifsfirst.endoff > endoff) {
6494 while (ifsfirst.next) { 6494 while (ifsfirst.next) {
6495 struct ifsregion *ifsp; 6495 struct ifsregion *ifsp;
6496 INT_OFF; 6496 INTOFF;
6497 ifsp = ifsfirst.next->next; 6497 ifsp = ifsfirst.next->next;
6498 free(ifsfirst.next); 6498 free(ifsfirst.next);
6499 ifsfirst.next = ifsp; 6499 ifsfirst.next = ifsp;
6500 INT_ON; 6500 INTON;
6501 } 6501 }
6502 if (ifsfirst.begoff > endoff) { 6502 if (ifsfirst.begoff > endoff) {
6503 ifslastp = NULL; 6503 ifslastp = NULL;
@@ -6513,11 +6513,11 @@ removerecordregions(int endoff)
6513 ifslastp = ifslastp->next; 6513 ifslastp = ifslastp->next;
6514 while (ifslastp->next) { 6514 while (ifslastp->next) {
6515 struct ifsregion *ifsp; 6515 struct ifsregion *ifsp;
6516 INT_OFF; 6516 INTOFF;
6517 ifsp = ifslastp->next->next; 6517 ifsp = ifslastp->next->next;
6518 free(ifslastp->next); 6518 free(ifslastp->next);
6519 ifslastp->next = ifsp; 6519 ifslastp->next = ifsp;
6520 INT_ON; 6520 INTON;
6521 } 6521 }
6522 if (ifslastp->endoff > endoff) 6522 if (ifslastp->endoff > endoff)
6523 ifslastp->endoff = endoff; 6523 ifslastp->endoff = endoff;
@@ -6632,7 +6632,7 @@ evalbackcmd(union node *n, struct backcmd *result
6632 jp = (ctl == CTLBACKQ) ? makejob(1) : NULL; 6632 jp = (ctl == CTLBACKQ) ? makejob(1) : NULL;
6633 if (forkshell(jp, n, FORK_NOJOB) == 0) { 6633 if (forkshell(jp, n, FORK_NOJOB) == 0) {
6634 /* child */ 6634 /* child */
6635 FORCE_INT_ON; 6635 FORCEINTON;
6636 close(pip[ip]); 6636 close(pip[ip]);
6637 /* ic is index of child end of pipe *and* fd to connect it to */ 6637 /* ic is index of child end of pipe *and* fd to connect it to */
6638 if (pip[ic] != ic) { 6638 if (pip[ic] != ic) {
@@ -6693,7 +6693,7 @@ expbackq(union node *cmd, int flag IF_BASH_PROCESS_SUBST(, int ctl))
6693 if (flag & EXP_DISCARD) 6693 if (flag & EXP_DISCARD)
6694 goto out; 6694 goto out;
6695 6695
6696 INT_OFF; 6696 INTOFF;
6697 startloc = expdest - (char *)stackblock(); 6697 startloc = expdest - (char *)stackblock();
6698 pushstackmark(&smark, startloc); 6698 pushstackmark(&smark, startloc);
6699 evalbackcmd(cmd, &in IF_BASH_PROCESS_SUBST(, ctl)); 6699 evalbackcmd(cmd, &in IF_BASH_PROCESS_SUBST(, ctl));
@@ -6727,7 +6727,7 @@ expbackq(union node *cmd, int flag IF_BASH_PROCESS_SUBST(, int ctl))
6727 back_exitstatus = waitforjob(in.jp); 6727 back_exitstatus = waitforjob(in.jp);
6728 } 6728 }
6729 done: 6729 done:
6730 INT_ON; 6730 INTON;
6731 6731
6732 /* Eat all trailing newlines */ 6732 /* Eat all trailing newlines */
6733 dest = expdest; 6733 dest = expdest;
@@ -7825,7 +7825,7 @@ expandmeta(struct strlist *str /*, int flag*/)
7825 if (!hasmeta(str->text)) 7825 if (!hasmeta(str->text))
7826 goto nometa; 7826 goto nometa;
7827 7827
7828 INT_OFF; 7828 INTOFF;
7829 p = preglob(str->text, RMESCAPE_ALLOC | RMESCAPE_HEAP); 7829 p = preglob(str->text, RMESCAPE_ALLOC | RMESCAPE_HEAP);
7830// GLOB_NOMAGIC (GNU): if no *?[ chars in pattern, return it even if no match 7830// GLOB_NOMAGIC (GNU): if no *?[ chars in pattern, return it even if no match
7831// GLOB_NOCHECK: if no match, return unchanged pattern (sans \* escapes?) 7831// GLOB_NOCHECK: if no match, return unchanged pattern (sans \* escapes?)
@@ -7856,12 +7856,12 @@ expandmeta(struct strlist *str /*, int flag*/)
7856#endif 7856#endif
7857 addglob(&pglob); 7857 addglob(&pglob);
7858 globfree(&pglob); 7858 globfree(&pglob);
7859 INT_ON; 7859 INTON;
7860 break; 7860 break;
7861 case GLOB_NOMATCH: 7861 case GLOB_NOMATCH:
7862 //nometa2: 7862 //nometa2:
7863 globfree(&pglob); 7863 globfree(&pglob);
7864 INT_ON; 7864 INTON;
7865 nometa: 7865 nometa:
7866 *exparg.lastp = str; 7866 *exparg.lastp = str;
7867 rmescapes(str->text, 0, NULL); 7867 rmescapes(str->text, 0, NULL);
@@ -7869,7 +7869,7 @@ expandmeta(struct strlist *str /*, int flag*/)
7869 break; 7869 break;
7870 default: /* GLOB_NOSPACE */ 7870 default: /* GLOB_NOSPACE */
7871 globfree(&pglob); 7871 globfree(&pglob);
7872 INT_ON; 7872 INTON;
7873 ash_msg_and_raise_error(bb_msg_memory_exhausted); 7873 ash_msg_and_raise_error(bb_msg_memory_exhausted);
7874 } 7874 }
7875 str = str->next; 7875 str = str->next;
@@ -8093,7 +8093,7 @@ expandmeta(struct strlist *str /*, int flag*/)
8093 goto nometa; 8093 goto nometa;
8094 savelastp = exparg.lastp; 8094 savelastp = exparg.lastp;
8095 8095
8096 INT_OFF; 8096 INTOFF;
8097 p = preglob(str->text, RMESCAPE_ALLOC | RMESCAPE_HEAP); 8097 p = preglob(str->text, RMESCAPE_ALLOC | RMESCAPE_HEAP);
8098 len = strlen(p); 8098 len = strlen(p);
8099 exp.dir_max = len + PATH_MAX; 8099 exp.dir_max = len + PATH_MAX;
@@ -8103,7 +8103,7 @@ expandmeta(struct strlist *str /*, int flag*/)
8103 free(exp.dir); 8103 free(exp.dir);
8104 if (p != str->text) 8104 if (p != str->text)
8105 free(p); 8105 free(p);
8106 INT_ON; 8106 INTON;
8107 if (exparg.lastp == savelastp) { 8107 if (exparg.lastp == savelastp) {
8108 /* 8108 /*
8109 * no matches 8109 * no matches
@@ -8423,7 +8423,7 @@ clearcmdentry(void)
8423 struct tblentry **pp; 8423 struct tblentry **pp;
8424 struct tblentry *cmdp; 8424 struct tblentry *cmdp;
8425 8425
8426 INT_OFF; 8426 INTOFF;
8427 for (tblp = cmdtable; tblp < &cmdtable[CMDTABLESIZE]; tblp++) { 8427 for (tblp = cmdtable; tblp < &cmdtable[CMDTABLESIZE]; tblp++) {
8428 pp = tblp; 8428 pp = tblp;
8429 while ((cmdp = *pp) != NULL) { 8429 while ((cmdp = *pp) != NULL) {
@@ -8440,7 +8440,7 @@ clearcmdentry(void)
8440 } 8440 }
8441 } 8441 }
8442 } 8442 }
8443 INT_ON; 8443 INTON;
8444} 8444}
8445 8445
8446/* 8446/*
@@ -8494,13 +8494,13 @@ delete_cmd_entry(void)
8494{ 8494{
8495 struct tblentry *cmdp; 8495 struct tblentry *cmdp;
8496 8496
8497 INT_OFF; 8497 INTOFF;
8498 cmdp = *lastcmdentry; 8498 cmdp = *lastcmdentry;
8499 *lastcmdentry = cmdp->next; 8499 *lastcmdentry = cmdp->next;
8500 if (cmdp->cmdtype == CMDFUNCTION) 8500 if (cmdp->cmdtype == CMDFUNCTION)
8501 freefunc(cmdp->param.func); 8501 freefunc(cmdp->param.func);
8502 free(cmdp); 8502 free(cmdp);
8503 INT_ON; 8503 INTON;
8504} 8504}
8505 8505
8506/* 8506/*
@@ -9234,11 +9234,11 @@ defun(union node *func)
9234{ 9234{
9235 struct cmdentry entry; 9235 struct cmdentry entry;
9236 9236
9237 INT_OFF; 9237 INTOFF;
9238 entry.cmdtype = CMDFUNCTION; 9238 entry.cmdtype = CMDFUNCTION;
9239 entry.u.func = copyfunc(func); 9239 entry.u.func = copyfunc(func);
9240 addcmdentry(func->ndefun.text, &entry); 9240 addcmdentry(func->ndefun.text, &entry);
9241 INT_ON; 9241 INTON;
9242} 9242}
9243 9243
9244/* Reasons for skipping commands (see comment on breakcmd routine) */ 9244/* Reasons for skipping commands (see comment on breakcmd routine) */
@@ -9607,13 +9607,13 @@ evalsubshell(union node *n, int flags)
9607 expredir(n->nredir.redirect); 9607 expredir(n->nredir.redirect);
9608 if (!backgnd && (flags & EV_EXIT) && !may_have_traps) 9608 if (!backgnd && (flags & EV_EXIT) && !may_have_traps)
9609 goto nofork; 9609 goto nofork;
9610 INT_OFF; 9610 INTOFF;
9611 if (backgnd == FORK_FG) 9611 if (backgnd == FORK_FG)
9612 get_tty_state(); 9612 get_tty_state();
9613 jp = makejob(1); 9613 jp = makejob(1);
9614 if (forkshell(jp, n, backgnd) == 0) { 9614 if (forkshell(jp, n, backgnd) == 0) {
9615 /* child */ 9615 /* child */
9616 INT_ON; 9616 INTON;
9617 flags |= EV_EXIT; 9617 flags |= EV_EXIT;
9618 if (backgnd) 9618 if (backgnd)
9619 flags &= ~EV_TESTED; 9619 flags &= ~EV_TESTED;
@@ -9626,7 +9626,7 @@ evalsubshell(union node *n, int flags)
9626 status = 0; 9626 status = 0;
9627 if (backgnd == FORK_FG) 9627 if (backgnd == FORK_FG)
9628 status = waitforjob(jp); 9628 status = waitforjob(jp);
9629 INT_ON; 9629 INTON;
9630 return status; 9630 return status;
9631} 9631}
9632 9632
@@ -9714,7 +9714,7 @@ evalpipe(union node *n, int flags)
9714 for (lp = n->npipe.cmdlist; lp; lp = lp->next) 9714 for (lp = n->npipe.cmdlist; lp; lp = lp->next)
9715 pipelen++; 9715 pipelen++;
9716 flags |= EV_EXIT; 9716 flags |= EV_EXIT;
9717 INT_OFF; 9717 INTOFF;
9718 if (n->npipe.pipe_backgnd == 0) 9718 if (n->npipe.pipe_backgnd == 0)
9719 get_tty_state(); 9719 get_tty_state();
9720 jp = makejob(pipelen); 9720 jp = makejob(pipelen);
@@ -9730,7 +9730,7 @@ evalpipe(union node *n, int flags)
9730 } 9730 }
9731 if (forkshell(jp, lp->n, n->npipe.pipe_backgnd) == 0) { 9731 if (forkshell(jp, lp->n, n->npipe.pipe_backgnd) == 0) {
9732 /* child */ 9732 /* child */
9733 INT_ON; 9733 INTON;
9734 if (pip[1] >= 0) { 9734 if (pip[1] >= 0) {
9735 close(pip[0]); 9735 close(pip[0]);
9736 } 9736 }
@@ -9757,7 +9757,7 @@ evalpipe(union node *n, int flags)
9757 status = waitforjob(jp); 9757 status = waitforjob(jp);
9758 TRACE(("evalpipe: job done exit status %d\n", status)); 9758 TRACE(("evalpipe: job done exit status %d\n", status));
9759 } 9759 }
9760 INT_ON; 9760 INTON;
9761 9761
9762 return status; 9762 return status;
9763} 9763}
@@ -9849,7 +9849,7 @@ poplocalvars(int keep)
9849 struct localvar *lvp, *next; 9849 struct localvar *lvp, *next;
9850 struct var *vp; 9850 struct var *vp;
9851 9851
9852 INT_OFF; 9852 INTOFF;
9853 ll = localvar_stack; 9853 ll = localvar_stack;
9854 localvar_stack = ll->next; 9854 localvar_stack = ll->next;
9855 9855
@@ -9893,7 +9893,7 @@ poplocalvars(int keep)
9893 } 9893 }
9894 free(lvp); 9894 free(lvp);
9895 } 9895 }
9896 INT_ON; 9896 INTON;
9897} 9897}
9898 9898
9899/* 9899/*
@@ -9909,12 +9909,12 @@ pushlocalvars(int push)
9909 if (!push) 9909 if (!push)
9910 goto out; 9910 goto out;
9911 9911
9912 INT_OFF; 9912 INTOFF;
9913 ll = ckzalloc(sizeof(*ll)); 9913 ll = ckzalloc(sizeof(*ll));
9914 /*ll->lv = NULL; - zalloc did it */ 9914 /*ll->lv = NULL; - zalloc did it */
9915 ll->next = top; 9915 ll->next = top;
9916 localvar_stack = ll; 9916 localvar_stack = ll;
9917 INT_ON; 9917 INTON;
9918 out: 9918 out:
9919 return top; 9919 return top;
9920} 9920}
@@ -9951,13 +9951,13 @@ evalfun(struct funcnode *func, int argc, char **argv, int flags)
9951 if (e) { 9951 if (e) {
9952 goto funcdone; 9952 goto funcdone;
9953 } 9953 }
9954 INT_OFF; 9954 INTOFF;
9955 exception_handler = &jmploc; 9955 exception_handler = &jmploc;
9956 shellparam.malloced = 0; 9956 shellparam.malloced = 0;
9957 func->count++; 9957 func->count++;
9958 funcname = func->n.ndefun.text; 9958 funcname = func->n.ndefun.text;
9959 funcline = func->n.ndefun.linno; 9959 funcline = func->n.ndefun.linno;
9960 INT_ON; 9960 INTON;
9961 shellparam.nparam = argc - 1; 9961 shellparam.nparam = argc - 1;
9962 shellparam.p = argv + 1; 9962 shellparam.p = argv + 1;
9963#if ENABLE_ASH_GETOPTS 9963#if ENABLE_ASH_GETOPTS
@@ -9966,7 +9966,7 @@ evalfun(struct funcnode *func, int argc, char **argv, int flags)
9966#endif 9966#endif
9967 evaltree(func->n.ndefun.body, flags & EV_TESTED); 9967 evaltree(func->n.ndefun.body, flags & EV_TESTED);
9968 funcdone: 9968 funcdone:
9969 INT_OFF; 9969 INTOFF;
9970 funcname = savefuncname; 9970 funcname = savefuncname;
9971 if (savetrap) { 9971 if (savetrap) {
9972 if (!trap[NTRAP_ERR]) 9972 if (!trap[NTRAP_ERR])
@@ -9980,7 +9980,7 @@ evalfun(struct funcnode *func, int argc, char **argv, int flags)
9980 freeparam(&shellparam); 9980 freeparam(&shellparam);
9981 shellparam = saveparam; 9981 shellparam = saveparam;
9982 exception_handler = savehandler; 9982 exception_handler = savehandler;
9983 INT_ON; 9983 INTON;
9984 evalskip &= ~(SKIPFUNC | SKIPFUNCDEF); 9984 evalskip &= ~(SKIPFUNC | SKIPFUNCDEF);
9985 return e; 9985 return e;
9986} 9986}
@@ -9999,7 +9999,7 @@ mklocal(char *name, int flags)
9999 struct var *vp; 9999 struct var *vp;
10000 char *eq = strchr(name, '='); 10000 char *eq = strchr(name, '=');
10001 10001
10002 INT_OFF; 10002 INTOFF;
10003 /* Cater for duplicate "local". Examples: 10003 /* Cater for duplicate "local". Examples:
10004 * x=0; f() { local x=1; echo $x; local x; echo $x; }; f; echo $x 10004 * x=0; f() { local x=1; echo $x; local x; echo $x; }; f; echo $x
10005 * x=0; f() { local x=1; echo $x; local x=2; echo $x; }; f; echo $x 10005 * x=0; f() { local x=1; echo $x; local x=2; echo $x; }; f; echo $x
@@ -10050,7 +10050,7 @@ mklocal(char *name, int flags)
10050 lvp->next = localvar_stack->lv; 10050 lvp->next = localvar_stack->lv;
10051 localvar_stack->lv = lvp; 10051 localvar_stack->lv = lvp;
10052 ret: 10052 ret:
10053 INT_ON; 10053 INTON;
10054} 10054}
10055 10055
10056/* 10056/*
@@ -10586,7 +10586,7 @@ evalcommand(union node *cmd, int flags)
10586 if (applet_no >= 0 && APPLET_IS_NOFORK(applet_no)) { 10586 if (applet_no >= 0 && APPLET_IS_NOFORK(applet_no)) {
10587 char **sv_environ; 10587 char **sv_environ;
10588 10588
10589 INT_OFF; 10589 INTOFF;
10590 sv_environ = environ; 10590 sv_environ = environ;
10591 environ = listvars(VEXPORT, VUNSET, varlist.list, /*end:*/ NULL); 10591 environ = listvars(VEXPORT, VUNSET, varlist.list, /*end:*/ NULL);
10592 /* 10592 /*
@@ -10608,7 +10608,7 @@ evalcommand(union node *cmd, int flags)
10608 * our signals to SA_RESTART? 10608 * our signals to SA_RESTART?
10609 */ 10609 */
10610 /*clearerr(stdout);*/ 10610 /*clearerr(stdout);*/
10611 INT_ON; 10611 INTON;
10612 break; 10612 break;
10613 } 10613 }
10614#endif 10614#endif
@@ -10618,7 +10618,7 @@ evalcommand(union node *cmd, int flags)
10618 */ 10618 */
10619 if (!(flags & EV_EXIT) || may_have_traps) { 10619 if (!(flags & EV_EXIT) || may_have_traps) {
10620 /* No, forking off a child is necessary */ 10620 /* No, forking off a child is necessary */
10621 INT_OFF; 10621 INTOFF;
10622 get_tty_state(); 10622 get_tty_state();
10623 jp = makejob(1); 10623 jp = makejob(1);
10624 if (forkshell(jp, cmd, FORK_FG) != 0) { 10624 if (forkshell(jp, cmd, FORK_FG) != 0) {
@@ -10626,7 +10626,7 @@ evalcommand(union node *cmd, int flags)
10626 break; 10626 break;
10627 } 10627 }
10628 /* child */ 10628 /* child */
10629 FORCE_INT_ON; 10629 FORCEINTON;
10630 /* fall through to exec'ing external program */ 10630 /* fall through to exec'ing external program */
10631 } 10631 }
10632 shellexec(argv[0], argv, path, cmdentry.u.index); 10632 shellexec(argv[0], argv, path, cmdentry.u.index);
@@ -10650,7 +10650,7 @@ evalcommand(union node *cmd, int flags)
10650 status = waitforjob(jp); 10650 status = waitforjob(jp);
10651 if (jp) 10651 if (jp)
10652 TRACE(("forked child exited with %d\n", status)); 10652 TRACE(("forked child exited with %d\n", status));
10653 FORCE_INT_ON; 10653 FORCEINTON;
10654 10654
10655 out: 10655 out:
10656 if (cmd->ncmd.redirect) 10656 if (cmd->ncmd.redirect)
@@ -10787,7 +10787,7 @@ pushstring(char *s, struct alias *ap)
10787 int len; 10787 int len;
10788 10788
10789 len = strlen(s); 10789 len = strlen(s);
10790 INT_OFF; 10790 INTOFF;
10791 if (g_parsefile->strpush || g_parsefile->spfree) { 10791 if (g_parsefile->strpush || g_parsefile->spfree) {
10792 sp = ckzalloc(sizeof(*sp)); 10792 sp = ckzalloc(sizeof(*sp));
10793 sp->prev = g_parsefile->strpush; 10793 sp->prev = g_parsefile->strpush;
@@ -10811,14 +10811,14 @@ pushstring(char *s, struct alias *ap)
10811 g_parsefile->left_in_line = len; 10811 g_parsefile->left_in_line = len;
10812 g_parsefile->unget = 0; 10812 g_parsefile->unget = 0;
10813 g_parsefile->spfree = NULL; 10813 g_parsefile->spfree = NULL;
10814 INT_ON; 10814 INTON;
10815} 10815}
10816 10816
10817static void popstring(void) 10817static void popstring(void)
10818{ 10818{
10819 struct strpush *sp = g_parsefile->strpush; 10819 struct strpush *sp = g_parsefile->strpush;
10820 10820
10821 INT_OFF; 10821 INTOFF;
10822#if ENABLE_ASH_ALIAS 10822#if ENABLE_ASH_ALIAS
10823 if (sp->ap) { 10823 if (sp->ap) {
10824 if (g_parsefile->next_to_pgetc[-1] == ' ' 10824 if (g_parsefile->next_to_pgetc[-1] == ' '
@@ -10837,7 +10837,7 @@ static void popstring(void)
10837 memcpy(g_parsefile->lastc, sp->lastc, sizeof(sp->lastc)); 10837 memcpy(g_parsefile->lastc, sp->lastc, sizeof(sp->lastc));
10838 g_parsefile->strpush = sp->prev; 10838 g_parsefile->strpush = sp->prev;
10839 g_parsefile->spfree = sp; 10839 g_parsefile->spfree = sp;
10840 INT_ON; 10840 INTON;
10841} 10841}
10842 10842
10843static int 10843static int
@@ -10882,11 +10882,11 @@ preadfd(void)
10882 * #(bash 5.0.17 exits after first "T", looks like a bug) 10882 * #(bash 5.0.17 exits after first "T", looks like a bug)
10883 */ 10883 */
10884 bb_got_signal = 0; 10884 bb_got_signal = 0;
10885 INT_OFF; /* no longjmp'ing out of read_line_input please */ 10885 INTOFF; /* no longjmp'ing out of read_line_input please */
10886 nr = read_line_input(line_input_state, cmdedit_prompt, buf, IBUFSIZ); 10886 nr = read_line_input(line_input_state, cmdedit_prompt, buf, IBUFSIZ);
10887 if (bb_got_signal == SIGINT) 10887 if (bb_got_signal == SIGINT)
10888 write(STDOUT_FILENO, "^C\n", 3); 10888 write(STDOUT_FILENO, "^C\n", 3);
10889 INT_ON; /* here non-blocked SIGINT will longjmp */ 10889 INTON; /* here non-blocked SIGINT will longjmp */
10890 if (nr == 0) { 10890 if (nr == 0) {
10891 /* ^C pressed, "convert" to SIGINT */ 10891 /* ^C pressed, "convert" to SIGINT */
10892 write(STDOUT_FILENO, "^C\n", 3); 10892 write(STDOUT_FILENO, "^C\n", 3);
@@ -11039,7 +11039,7 @@ nlnoprompt(void)
11039 11039
11040static void freestrings(struct strpush *sp) 11040static void freestrings(struct strpush *sp)
11041{ 11041{
11042 INT_OFF; 11042 INTOFF;
11043 do { 11043 do {
11044 struct strpush *psp; 11044 struct strpush *psp;
11045#if ENABLE_ASH_ALIAS 11045#if ENABLE_ASH_ALIAS
@@ -11058,7 +11058,7 @@ static void freestrings(struct strpush *sp)
11058 } while (sp); 11058 } while (sp);
11059 11059
11060 g_parsefile->spfree = NULL; 11060 g_parsefile->spfree = NULL;
11061 INT_ON; 11061 INTON;
11062} 11062}
11063 11063
11064static int __pgetc(void) 11064static int __pgetc(void)
@@ -11191,7 +11191,7 @@ popfile(void)
11191 if (pf == &basepf) 11191 if (pf == &basepf)
11192 return; 11192 return;
11193 11193
11194 INT_OFF; 11194 INTOFF;
11195 if (pf->pf_fd >= 0) 11195 if (pf->pf_fd >= 0)
11196 close(pf->pf_fd); 11196 close(pf->pf_fd);
11197 free(pf->buf); 11197 free(pf->buf);
@@ -11203,7 +11203,7 @@ popfile(void)
11203 } 11203 }
11204 g_parsefile = pf->prev; 11204 g_parsefile = pf->prev;
11205 free(pf); 11205 free(pf);
11206 INT_ON; 11206 INTON;
11207} 11207}
11208 11208
11209static void 11209static void
@@ -11264,7 +11264,7 @@ setinputfile(const char *fname, int flags)
11264{ 11264{
11265 int fd; 11265 int fd;
11266 11266
11267 INT_OFF; 11267 INTOFF;
11268 fd = open(fname, O_RDONLY | O_CLOEXEC); 11268 fd = open(fname, O_RDONLY | O_CLOEXEC);
11269 if (fd < 0) { 11269 if (fd < 0) {
11270 if (flags & INPUT_NOFILE_OK) 11270 if (flags & INPUT_NOFILE_OK)
@@ -11279,7 +11279,7 @@ setinputfile(const char *fname, int flags)
11279 11279
11280 setinputfd(fd, flags & INPUT_PUSH_FILE); 11280 setinputfd(fd, flags & INPUT_PUSH_FILE);
11281 out: 11281 out:
11282 INT_ON; 11282 INTON;
11283 return fd; 11283 return fd;
11284} 11284}
11285 11285
@@ -11289,13 +11289,13 @@ setinputfile(const char *fname, int flags)
11289static void 11289static void
11290setinputstring(char *string) 11290setinputstring(char *string)
11291{ 11291{
11292 INT_OFF; 11292 INTOFF;
11293 pushfile(); 11293 pushfile();
11294 g_parsefile->next_to_pgetc = string; 11294 g_parsefile->next_to_pgetc = string;
11295 g_parsefile->left_in_line = strlen(string); 11295 g_parsefile->left_in_line = strlen(string);
11296 g_parsefile->buf = NULL; 11296 g_parsefile->buf = NULL;
11297 g_parsefile->linno = lineno; 11297 g_parsefile->linno = lineno;
11298 INT_ON; 11298 INTON;
11299} 11299}
11300 11300
11301 11301
@@ -11555,7 +11555,7 @@ shiftcmd(int argc UNUSED_PARAM, char **argv)
11555 n = number(argv[1]); 11555 n = number(argv[1]);
11556 if (n > shellparam.nparam) 11556 if (n > shellparam.nparam)
11557 return 1; 11557 return 1;
11558 INT_OFF; 11558 INTOFF;
11559 shellparam.nparam -= n; 11559 shellparam.nparam -= n;
11560 for (ap1 = shellparam.p; --n >= 0; ap1++) { 11560 for (ap1 = shellparam.p; --n >= 0; ap1++) {
11561 if (shellparam.malloced) 11561 if (shellparam.malloced)
@@ -11568,7 +11568,7 @@ shiftcmd(int argc UNUSED_PARAM, char **argv)
11568 shellparam.optind = 1; 11568 shellparam.optind = 1;
11569 shellparam.optoff = -1; 11569 shellparam.optoff = -1;
11570#endif 11570#endif
11571 INT_ON; 11571 INTON;
11572 return 0; 11572 return 0;
11573} 11573}
11574 11574
@@ -11622,7 +11622,7 @@ setcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
11622 if (!argv[1]) 11622 if (!argv[1])
11623 return showvars(nullstr, 0, VUNSET); 11623 return showvars(nullstr, 0, VUNSET);
11624 11624
11625 INT_OFF; 11625 INTOFF;
11626 retval = options(/*login_sh:*/ NULL); 11626 retval = options(/*login_sh:*/ NULL);
11627 if (retval == 0) { /* if no parse error... */ 11627 if (retval == 0) { /* if no parse error... */
11628 optschanged(); 11628 optschanged();
@@ -11630,7 +11630,7 @@ setcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
11630 setparam(argptr); 11630 setparam(argptr);
11631 } 11631 }
11632 } 11632 }
11633 INT_ON; 11633 INTON;
11634 return retval; 11634 return retval;
11635} 11635}
11636 11636
@@ -13629,7 +13629,7 @@ cmdloop(int top)
13629 13629
13630 setstackmark(&smark); 13630 setstackmark(&smark);
13631#if JOBS 13631#if JOBS
13632 if (doing_jobctl) 13632 if (jobctl)
13633 showjobs(SHOW_CHANGED|SHOW_STDERR); 13633 showjobs(SHOW_CHANGED|SHOW_STDERR);
13634#endif 13634#endif
13635 inter = 0; 13635 inter = 0;
@@ -14003,11 +14003,11 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path)
14003 entry->u.index = idx; 14003 entry->u.index = idx;
14004 return; 14004 return;
14005 } 14005 }
14006 INT_OFF; 14006 INTOFF;
14007 cmdp = cmdlookup(name, 1); 14007 cmdp = cmdlookup(name, 1);
14008 cmdp->cmdtype = CMDNORMAL; 14008 cmdp->cmdtype = CMDNORMAL;
14009 cmdp->param.index = idx; 14009 cmdp->param.index = idx;
14010 INT_ON; 14010 INTON;
14011 goto success; 14011 goto success;
14012 } 14012 }
14013 14013
@@ -14039,11 +14039,11 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path)
14039 entry->u.cmd = bcmd; 14039 entry->u.cmd = bcmd;
14040 return; 14040 return;
14041 } 14041 }
14042 INT_OFF; 14042 INTOFF;
14043 cmdp = cmdlookup(name, 1); 14043 cmdp = cmdlookup(name, 1);
14044 cmdp->cmdtype = CMDBUILTIN; 14044 cmdp->cmdtype = CMDBUILTIN;
14045 cmdp->param.cmd = bcmd; 14045 cmdp->param.cmd = bcmd;
14046 INT_ON; 14046 INTON;
14047 success: 14047 success:
14048 cmdp->rehash = 0; 14048 cmdp->rehash = 0;
14049 entry->cmdtype = cmdp->cmdtype; 14049 entry->cmdtype = cmdp->cmdtype;
@@ -14105,7 +14105,7 @@ trapcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
14105 exitcode = 1; 14105 exitcode = 1;
14106 goto next; 14106 goto next;
14107 } 14107 }
14108 INT_OFF; 14108 INTOFF;
14109 if (action) { 14109 if (action) {
14110 if (LONE_DASH(action)) 14110 if (LONE_DASH(action))
14111 action = NULL; 14111 action = NULL;
@@ -14119,7 +14119,7 @@ trapcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
14119 trap[signo] = action; 14119 trap[signo] = action;
14120 if (signo != 0 && signo < NSIG) 14120 if (signo != 0 && signo < NSIG)
14121 setsignal(signo); 14121 setsignal(signo);
14122 INT_ON; 14122 INTON;
14123 next: 14123 next:
14124 ap++; 14124 ap++;
14125 } 14125 }
@@ -14395,9 +14395,9 @@ readcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
14395 * to jump out of it. 14395 * to jump out of it.
14396 */ 14396 */
14397 again: 14397 again:
14398 INT_OFF; 14398 INTOFF;
14399 r = shell_builtin_read(&params); 14399 r = shell_builtin_read(&params);
14400 INT_ON; 14400 INTON;
14401 14401
14402 if ((uintptr_t)r == 1 && errno == EINTR) { 14402 if ((uintptr_t)r == 1 && errno == EINTR) {
14403 /* To get SIGCHLD: sleep 1 & read x; echo $x 14403 /* To get SIGCHLD: sleep 1 & read x; echo $x
@@ -14430,10 +14430,10 @@ umaskcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
14430 symbolic_mode = 1; 14430 symbolic_mode = 1;
14431 } 14431 }
14432 14432
14433 INT_OFF; 14433 INTOFF;
14434 mask = umask(0); 14434 mask = umask(0);
14435 umask(mask); 14435 umask(mask);
14436 INT_ON; 14436 INTON;
14437 14437
14438 if (*argptr == NULL) { 14438 if (*argptr == NULL) {
14439 if (symbolic_mode) { 14439 if (symbolic_mode) {
@@ -14806,7 +14806,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
14806 } 14806 }
14807 14807
14808 popstackmark(&smark); 14808 popstackmark(&smark);
14809 FORCE_INT_ON; /* enable interrupts */ 14809 FORCEINTON; /* enable interrupts */
14810 if (s == 1) 14810 if (s == 1)
14811 goto state1; 14811 goto state1;
14812 if (s == 2) 14812 if (s == 2)
@@ -14883,11 +14883,11 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
14883 if (!hp) { 14883 if (!hp) {
14884 hp = lookupvar("HOME"); 14884 hp = lookupvar("HOME");
14885 if (hp) { 14885 if (hp) {
14886 INT_OFF; 14886 INTOFF;
14887 hp = concat_path_file(hp, ".ash_history"); 14887 hp = concat_path_file(hp, ".ash_history");
14888 setvar0("HISTFILE", hp); 14888 setvar0("HISTFILE", hp);
14889 free((char*)hp); 14889 free((char*)hp);
14890 INT_ON; 14890 INTON;
14891 hp = lookupvar("HISTFILE"); 14891 hp = lookupvar("HISTFILE");
14892 } 14892 }
14893 } 14893 }