Skip to content

Add ::exit(Process::Status)#16436

Merged
straight-shoota merged 1 commit intocrystal-lang:masterfrom
straight-shoota:feat/process.exit-with-status
Dec 1, 2025
Merged

Add ::exit(Process::Status)#16436
straight-shoota merged 1 commit intocrystal-lang:masterfrom
straight-shoota:feat/process.exit-with-status

Conversation

@straight-shoota
Copy link
Member

This overload easily allows forwarding the exit status of a sub-process like this:

status = Process.run("exit 12", shell: true)
exit status

It's a component for building a Process.exec alternative with portable semantics (#14422). But I figure it can be useful on its own, so it should be exposed in the public API.

@straight-shoota straight-shoota added this to the 1.19.0 milestone Nov 27, 2025
@straight-shoota straight-shoota merged commit 6ca3b33 into crystal-lang:master Dec 1, 2025
51 checks passed
@straight-shoota straight-shoota deleted the feat/process.exit-with-status branch December 1, 2025 11:43
straight-shoota added a commit to crystal-lang/shards that referenced this pull request Dec 17, 2025
Use `Process.exec` on Unix systems to replace the current process.
This doesn't work on Windows (crystal-lang/crystal#14422), so we use `Process.run` instead, plus `exit(Process::Status)` on Crystal 1.19 (crystal-lang/crystal#16436) or a fallback (`exit status.system_exit_status.to_i32!`) on older versions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants