Skip to content

Commit f9209c2

Browse files
authored
Merge pull request #7337 from grondo/issue#7336
broker: fix hang on rc exec errors
2 parents b0a7515 + 8f28deb commit f9209c2

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/broker/runat.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,20 @@ static void completion_cb (flux_subprocess_t *p)
174174
rc = signum + 128;
175175
log_command (r->h, entry, rc, elapsed, strsignal (signum));
176176
}
177+
else if (flux_subprocess_state (p) == FLUX_SUBPROCESS_FAILED) {
178+
/* exec failure: process never started.
179+
*
180+
* mimic bash exit code (from bash(1)):
181+
*
182+
* If a command is not found, the child process created to execute
183+
* it returns a status of 127. If a command is found but is not
184+
* executable, the return status is 126.
185+
*/
186+
rc = 126;
187+
if (flux_subprocess_fail_errno (p) == ENOENT)
188+
rc = 127;
189+
log_command (r->h, entry, rc, elapsed, flux_subprocess_fail_error (p));
190+
}
177191
else { // ???
178192
rc = 1;
179193
log_command (r->h, entry, rc, elapsed, "???");
@@ -258,7 +272,9 @@ static void state_change_cb (flux_subprocess_t *p,
258272
switch (state) {
259273
case FLUX_SUBPROCESS_INIT:
260274
case FLUX_SUBPROCESS_EXITED:
275+
break;
261276
case FLUX_SUBPROCESS_FAILED:
277+
completion_cb (p);
262278
break;
263279
case FLUX_SUBPROCESS_STOPPED:
264280
/* STOPPED may arrive before RUNNING due to a protocol race

t/t0001-basic.t

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ test_expect_success 'flux-start fails with unknown option' "
200200
test_expect_success 'flux-start fails with --verbose=badopt' "
201201
test_must_fail flux start ${ARGS} --verbose=badopt true
202202
"
203+
test_expect_success 'flux-start fails with bad SHELL' '
204+
( export SHELL=/no/such/path &&
205+
test_expect_code 127 run_timeout 30 flux start flux uptime
206+
)
207+
'
203208
test_expect_success 'create bad broker shell script' '
204209
cat >flux-broker <<-EOT &&
205210
#!/badinterp

0 commit comments

Comments
 (0)