aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-07-24 00:16:59 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-07-24 00:16:59 +0200
commite56f22ac6072a6279782951fe7aaf633d4d6052a (patch)
treeec84507384a3eb5489b5de2ec82714a42d7f2f4e
parent86e83ec4872ee1d3156a5c019fde301497819ca3 (diff)
downloadbusybox-w32-e56f22ac6072a6279782951fe7aaf633d4d6052a.tar.gz
busybox-w32-e56f22ac6072a6279782951fe7aaf633d4d6052a.tar.bz2
busybox-w32-e56f22ac6072a6279782951fe7aaf633d4d6052a.zip
ash: make "jobs" work even in subshells
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/ash.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 304251662..613a66dbc 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -4541,8 +4541,11 @@ clear_traps(void)
4541static void closescript(void); 4541static void closescript(void);
4542 4542
4543/* Called after fork(), in child */ 4543/* Called after fork(), in child */
4544#if !JOBS
4545# define forkchild(jp, n, mode) forkchild(jp, mode)
4546#endif
4544static void 4547static void
4545forkchild(struct job *jp, /*union node *n,*/ int mode) 4548forkchild(struct job *jp, union node *n, int mode)
4546{ 4549{
4547 int oldlvl; 4550 int oldlvl;
4548 4551
@@ -4598,6 +4601,13 @@ forkchild(struct job *jp, /*union node *n,*/ int mode)
4598 * Take care of the second rule: */ 4601 * Take care of the second rule: */
4599 setsignal(SIGQUIT); 4602 setsignal(SIGQUIT);
4600 } 4603 }
4604#if JOBS
4605 if (n && n->type == NCMD && strcmp(n->ncmd.args->narg.text, "jobs") == 0) {
4606 TRACE(("Job hack\n"));
4607 freejob(curjob);
4608 return;
4609 }
4610#endif
4601 for (jp = curjob; jp; jp = jp->prev_job) 4611 for (jp = curjob; jp; jp = jp->prev_job)
4602 freejob(jp); 4612 freejob(jp);
4603 jobless = 0; 4613 jobless = 0;
@@ -4659,7 +4669,7 @@ forkshell(struct job *jp, union node *n, int mode)
4659 ash_msg_and_raise_error("can't fork"); 4669 ash_msg_and_raise_error("can't fork");
4660 } 4670 }
4661 if (pid == 0) 4671 if (pid == 0)
4662 forkchild(jp, /*n,*/ mode); 4672 forkchild(jp, n, mode);
4663 else 4673 else
4664 forkparent(jp, n, mode, pid); 4674 forkparent(jp, n, mode, pid);
4665 return pid; 4675 return pid;