Skip to content

Commit 69582a4

Browse files
committed
The set-display script needs to be sourced, not run
This removes the executable bit and shebang, names it `.sh` as is traditional for a file being sourced, and sources it. The reason it needs to be sourced is that it is using a symlink that goes through an entry specific to the current proces under `/proc`. This is done because the symlink is one of the symlinks in the process filesystem that has special semantics: it refers to stdout for the process, even when stdout is not a file that could otherwise be accessed with a path on disk. (We need that because the stdout and stderr streams in a GitHub Actions step go to an unnamed pipe object.) But if it is run as a script then the new shell instance that runs the script is the current process, which then goes away, breaking the symlink (or causing it go to the wrong place if another process is created that reuses the old PID).
1 parent 01c7b0e commit 69582a4

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

.github/workflows/ci.yml

+10-11
Original file line numberDiff line numberDiff line change
@@ -100,26 +100,25 @@ jobs:
100100
ln -s -- /usr/local/bin/wrapper1 "$base"
101101
EOF
102102
103-
# Define a script that wires up the `~/display` symlink that `wrapper1` uses to report
104-
# calls as GitHub Actions step output (in addition to writing them to a log file). This
105-
# is needed because stdout and stderr are both redirected elsewhere when the wrapper
106-
# actually runs, and `/dev/tty` is not usable. This script must be run in the same step
107-
# as the `cargo` command that causes wrapped executables to be run, because different
108-
# steps write to different pipe objects. (As implemented, this also needs the calling
109-
# shell to remain running, but that is not the cause of the underlying limitation.)
110-
cat >/usr/local/bin/set-display <<'EOF'
111-
#!/bin/sh
103+
# Define a helper file that, when sourced, wires up the `~/display` symlink `wrapper1`
104+
# uses to report calls as GitHub Actions step output (in addition to writing them to a
105+
# log file). This is needed because stdout and stderr are both redirected elsewhere when
106+
# the wrapper actually runs, and `/dev/tty` is not usable. This must be sourced in the
107+
# same step as the `cargo` command that causes wrapped executables to be run, because
108+
# different steps write to different pipe objects. (This also needs the shell that
109+
# sourced it to remain running. But that is not the cause of the underlying limitation.)
110+
cat >/usr/local/bin/set-display.sh <<'EOF'
112111
ln -s -- "/proc/$$/fd/1" ~/display
113112
EOF
114113
115-
chmod +x /usr/local/bin/wrapper1 /usr/local/bin/wrap1 /usr/local/bin/set-display
114+
chmod +x /usr/local/bin/wrapper1 /usr/local/bin/wrap1
116115
mkdir /run/lock/wrapper1.fbd136bd-9b1b-448d-84a9-e18be53ae63c.lock
117116
118117
find /usr/lib/gcc \( -name cc1 -o -name cc1plus \) \
119118
-print -exec /usr/local/bin/wrap1 {} \;
120119
- name: Build max-pure with limited dev tools and log cc1
121120
run: |
122-
/usr/local/bin/set-display
121+
. /usr/local/bin/set-display.sh
123122
cargo install --debug --locked --no-default-features --features max-pure --path .
124123
- name: Show logged C and C++ compilations (should be none)
125124
run: |

0 commit comments

Comments
 (0)