Fall back from /dev/tty to /dev/stdout in buildall single-shim builds#14913
Fall back from /dev/tty to /dev/stdout in buildall single-shim builds#14913revans2 wants to merge 2 commits into
Conversation
Single-shim/serial builds forced Maven output to /dev/tty, which has no controlling terminal in non-interactive contexts (CI, containers, xargs workers). Opening it fails and aborts the whole build. Fall back to /dev/stdout when /dev/tty cannot be opened, and skip the on-failure log tail for live streams since their output is already on screen. Signed-off-by: Robert (Bobby) Evans <bobby@apache.org>
Greptile SummaryThis PR makes the
Confidence Score: 5/5Safe to merge — the change is narrowly scoped to the serial/single-shim output-routing path and leaves parallel builds untouched. The TTY probe is a well-established bash idiom, the subshell correctly scopes the exec redirects, and the three output modes (live TTY, inherited stdout, log file) are all handled consistently in both the normal and failure paths. No logic that affects the Maven invocation itself is changed. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[build_single_shim called] --> B{BUILD_PARALLEL==1 OR NUM_SHIMS==1?}
B -- Yes --> C{Try: > /dev/tty}
C -- Success --> D[LOG_FILE=/dev/tty stream live to terminal]
C -- Fail / no TTY --> E[LOG_FILE=empty stream to inherited stdout]
B -- No / parallel --> F[LOG_FILE=mvn-build-VER.log write to file]
D --> G[exec subshell with Maven]
E --> G
F --> G
G -- Success --> H[Done]
G -- Failure --> I{case LOG_FILE}
I -- empty or /dev/tty --> J[output already visible, no tail needed]
I -- file path --> K[echo filename + tail last 500 lines]
J --> L[exit 255]
K --> L
Reviews (2): Last reviewed commit: "Addressed review comments" | Re-trigger Greptile |
amahussein
left a comment
There was a problem hiding this comment.
Thanks for fixing the no-tty case.
| if { : > /dev/tty; } 2>/dev/null; then | ||
| LOG_FILE="/dev/tty" | ||
| else | ||
| LOG_FILE="/dev/stdout" |
There was a problem hiding this comment.
falling back to /dev/stdout still reopens stdout by path, and that can fail in some non-interactive environments.
Would it be safer to make the no-tty path avoid a stdout filename entirely and just run Maven with the existing stdout, e.g. only redirect stderr with 2>&1? That should preserve the intended live output behavior without depending on /dev/stdout being reopenable.
Signed-off-by: Robert (Bobby) Evans <bobby@apache.org>
|
build |
Description
Small change that allows using buildall without a tty present. Better for automation or inside of a docker container.
Checklists
Documentation
Testing
(Please provide the names of the existing tests in the PR description.)
Performance