Skip to content

Commit

Permalink
testsuite: add test for job shell handling of SIGPIPE
Browse files Browse the repository at this point in the history
Problem: There's no test to ensure the job shell is not killed by
SIGPIPE when writing data to a task that has closed stdin.

Attempt to add a test for this issue. Add a note that the test is
inherently racy, and it is just a best effort at this time.
  • Loading branch information
grondo committed Dec 6, 2024
1 parent c46bdb6 commit 5fe12df
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions t/t2607-job-shell-input.t
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ test_expect_success LONGTEST 'flux-shell: 10K line lptest piped input works' '
test_cmp lptestXXL_input pipe3.out
'

# Note: This test is racy. It tries to ensure the shell has had a chance
# to read the stdin data and write to the target task, but the cancel could
# come before that since there is no way to synchronize. Thus, the test may
# give false positive results (ok) but never a false negative (no ok).
#
test_expect_success NO_CHAIN_LINT 'flux-shell: ignores SIGPIPE if task closes stdin' '
id=$(flux submit sh -c "exec <&-; sleep 60") &&
flux job wait-event $id start &&
flux job wait-event -vp exec $id shell.start &&
(echo foo | flux job attach $id &) &&
flux job wait-event -vp input $id data &&
flux cancel $id &&
test_expect_code 143 flux job status $id
'

#
# sharness will redirect /dev/null to stdin by default, so we create a named pipe
# and pipe that in for tests in which we need "no stdin".
Expand Down

0 comments on commit 5fe12df

Please sign in to comment.