aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-10-27 20:18:18 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2016-10-27 21:13:24 +0200
commit69188110146198c2c3fe7344c7d11dfac8891245 (patch)
tree326fcea82ac715d49d1b72d98a88888691ac00bf
parentb543bdadb3014661b6052c82b31e0012abc1e210 (diff)
downloadbusybox-w32-69188110146198c2c3fe7344c7d11dfac8891245.tar.gz
busybox-w32-69188110146198c2c3fe7344c7d11dfac8891245.tar.bz2
busybox-w32-69188110146198c2c3fe7344c7d11dfac8891245.zip
ash: open-code blocking_dowait_with_raise_on_sig()
There is in fact only one callsite. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/ash.c25
1 files changed, 7 insertions, 18 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 3a364dc2c..e21df3291 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -4032,15 +4032,6 @@ dowait(int block, struct job *job)
4032 return pid; 4032 return pid;
4033} 4033}
4034 4034
4035static int
4036blocking_dowait_with_raise_on_sig(void)
4037{
4038 pid_t pid = dowait(DOWAIT_BLOCK, NULL);
4039 if (pid <= 0 && pending_sig)
4040 raise_exception(EXSIG);
4041 return pid;
4042}
4043
4044#if JOBS 4035#if JOBS
4045static void 4036static void
4046showjob(struct job *jp, int mode) 4037showjob(struct job *jp, int mode)
@@ -4229,19 +4220,14 @@ waitcmd(int argc UNUSED_PARAM, char **argv)
4229 jp->waited = 1; 4220 jp->waited = 1;
4230 jp = jp->prev_job; 4221 jp = jp->prev_job;
4231 } 4222 }
4232 blocking_dowait_with_raise_on_sig(); 4223 dowait(DOWAIT_BLOCK, NULL);
4233 /* man bash: 4224 /* man bash:
4234 * "When bash is waiting for an asynchronous command via 4225 * "When bash is waiting for an asynchronous command via
4235 * the wait builtin, the reception of a signal for which a trap 4226 * the wait builtin, the reception of a signal for which a trap
4236 * has been set will cause the wait builtin to return immediately 4227 * has been set will cause the wait builtin to return immediately
4237 * with an exit status greater than 128, immediately after which 4228 * with an exit status greater than 128, immediately after which
4238 * the trap is executed." 4229 * the trap is executed."
4239 * 4230 */
4240 * blocking_dowait_with_raise_on_sig raises signal handlers
4241 * if it gets no pid (pid < 0). However,
4242 * if child sends us a signal *and immediately exits*,
4243 * blocking_dowait_with_raise_on_sig gets pid > 0
4244 * and does not handle pending_sig. Check this case: */
4245 if (pending_sig) 4231 if (pending_sig)
4246 raise_exception(EXSIG); 4232 raise_exception(EXSIG);
4247 } 4233 }
@@ -4263,8 +4249,11 @@ waitcmd(int argc UNUSED_PARAM, char **argv)
4263 job = getjob(*argv, 0); 4249 job = getjob(*argv, 0);
4264 } 4250 }
4265 /* loop until process terminated or stopped */ 4251 /* loop until process terminated or stopped */
4266 while (job->state == JOBRUNNING) 4252 while (job->state == JOBRUNNING) {
4267 blocking_dowait_with_raise_on_sig(); 4253 pid_t pid = dowait(DOWAIT_BLOCK, NULL);
4254 if (pid <= 0 && pending_sig)
4255 raise_exception(EXSIG);
4256 }
4268 job->waited = 1; 4257 job->waited = 1;
4269 retval = getstatus(job); 4258 retval = getstatus(job);
4270 repeat: ; 4259 repeat: ;