Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stdstream support #168

Merged
merged 9 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
19 changes: 19 additions & 0 deletions test/stdstream.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

TRY_TOP="${TRY_TOP:-$(git rev-parse --show-toplevel --show-superproject-working-tree 2>/dev/null || echo "${0%/*}")}"
TRY="$TRY_TOP/try"

cmdfile="$(mktemp)"

cat > "$cmdfile" <<"EOF"
ezrizhu marked this conversation as resolved.
Show resolved Hide resolved
file /dev/stdin
file /dev/stdout
file /dev/stderr
EOF

chmod +x "$cmdfile"

result=$("$TRY" "$cmdfile")
expected=$(sh "$cmdfile")

[ "$result" = "$expected" ] || exit 1
8 changes: 8 additions & 0 deletions try
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ unshare --root="$SANDBOX_DIR/temproot" /bin/sh "$chroot_executable"
exitcode="$?"

# unmount the devices
rm "$sandbox_dir/temproot/dev/stdin"
rm "$sandbox_dir/temproot/dev/stdout"
rm "$sandbox_dir/temproot/dev/stderr"

unmount_devices "$SANDBOX_DIR"

exit $exitcode
Expand All @@ -262,6 +266,10 @@ unset START_DIR SANDBOX_DIR UNION_HELPER DIRS_AND_MOUNTS TRY_EXIT_STATUS
unset script_to_execute chroot_executable try_mount_log

mount -t proc proc /proc &&
cd /dev &&
ln -s /proc/self/fd/0 stdin &&
ln -s /proc/self/fd/1 stdout &&
ln -s /proc/self/fd/2 stderr &&
cd "$START_DIR" &&
ezrizhu marked this conversation as resolved.
Show resolved Hide resolved
. "$script_to_execute"
EOF
Expand Down