Skip to content

Commit 04806da

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 fb67a78 commit 04806da

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

0 commit comments

Comments
 (0)