test: keep the porter abort case from passing without an abort - #943
Open
brahyam wants to merge 1 commit into
Open
test: keep the porter abort case from passing without an abort#943brahyam wants to merge 1 commit into
brahyam wants to merge 1 commit into
Conversation
The exec-kill path makes a command its own session leader with setsid, records that pid as a process group id, and cancels by killing the group. Where setsid is missing the wrapper fails to start at all and the exec returns 127 immediately, which satisfies both of this test's assertions — fast, and non-zero — so the case reported green without ever launching the command, let alone aborting one. Where setsid exists but does not create a session, the recorded pid is not a group id, the group kill finds nothing and the command runs to completion, failing the case for a reason that has nothing to do with the code under test. Probe for the property the mechanism actually needs, that setsid makes the command its own process group leader, and skip with that reason when it does not hold. Then assert the command started and did not finish, so an exec that never ran cannot satisfy the case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
test/porter-sandbox.test.ts's "abort signal kills an in-flight exec" has nohonest outcome on a host without a working
setsid.killableScriptwraps the command asexec setsid sh -c …, has the innershell record
$$as a process group id, andkillScriptcancels withkill -KILL -"$pgid". That is only correct whensetsidstarts a new session,which is what makes the inner shell a group leader so
pid == pgid.Where
setsidis missing, the wrapper never starts: the exec returns 127instantly, which satisfies both of the test's assertions — fast, and non-zero.
The case reports green without launching the command, let alone aborting one.
Where a
setsidexists that does not create a session (a#!/bin/sh/exec "$@"shim on PATH is enough), the recorded pid is not a group id, thegroup kill matches nothing, and the command runs to completion — failing the
case for a reason unrelated to the code under test.
This probes for the property the mechanism needs, that
setsidmakes acommand its own process group leader, and skips with that reason when it does
not hold. It then asserts the command started and did not finish, so an exec
that never ran cannot satisfy the case.
Verified in all three states:
setsidabsent → skips with the reason; anon-session shim on PATH → skips with the reason; a genuine
setsid→ runs andpasses in ~0.5s, with the two new assertions holding. Linux CI is the third
state, so coverage there is unchanged apart from the added assertions.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.