Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ jobs:
run: docker run --rm --net=none --privileged rootlesskit:test-integration ./integration-systemd-socket.sh
- name: "Integration test: pdeathsig"
run: docker run --rm --privileged rootlesskit:test-integration ./integration-pdeathsig.sh
- name: "Integration test: runWithoutReap"
run: docker run --rm --privileged rootlesskit:test-integration ./integration-run-without-reap.sh
- name: "Integration test: Network (network driver=slirp4netns)"
run: |
docker run --rm --privileged rootlesskit:test-integration ./integration-net.sh slirp4netns
Expand Down
42 changes: 42 additions & 0 deletions hack/integration-run-without-reap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
# Integration test for runWithoutReap (--reaper=false path).
# Regression test for https://github.com/rootless-containers/rootlesskit/issues/557
source $(realpath $(dirname $0))/common.inc.sh

INFO "Testing runWithoutReap: command execution"
out=$($ROOTLESSKIT --reaper=false echo hello 2>&1)
if ! echo "$out" | grep -q "hello"; then
ERROR "expected 'hello' in output, got: $out"
exit 1
fi

INFO "Testing runWithoutReap: exit code propagation"
set +e
$ROOTLESSKIT --reaper=false sh -c "exit 42" >/dev/null 2>&1
code=$?
set -e
if [ $code != 42 ]; then
ERROR "expected exit code 42, got $code"
exit 1
fi

INFO "Testing runWithoutReap: TTY preservation"
# Use script(1) to allocate a PTY; verify the child sees a TTY
# and does not print "cannot set terminal process group" (issue #557).
tmp=$(mktemp -d)
script -qec "$ROOTLESSKIT --reaper=false sh -c 'tty; echo DONE'" "$tmp/typescript" > "$tmp/out" 2>&1
if grep -qi "cannot set terminal process group" "$tmp/out"; then
ERROR "child lost its controlling terminal (setsid regression)"
cat "$tmp/out"
rm -rf "$tmp"
exit 1
fi
if ! grep -q "DONE" "$tmp/out"; then
ERROR "child did not complete"
cat "$tmp/out"
rm -rf "$tmp"
exit 1
fi
rm -rf "$tmp"

INFO "===== All runWithoutReap tests passed ====="
1 change: 0 additions & 1 deletion pkg/child/child.go
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please squash the commits

Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,6 @@ func setMountPropagation(propagation string) error {
}

func runWithoutReap(cmd *exec.Cmd) error {
cmd.SysProcAttr.Setsid = true
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to have a test?

if err := cmd.Start(); err != nil {
return err
}
Expand Down