Created
December 1, 2022 01:08
-
-
Save patmaddox/e7c4a105b5aa9bf5a5d185ba7175feff to your computer and use it in GitHub Desktop.
elixir port wrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Start the program in the background | |
exec "$@" & | |
pid1=$! | |
# Silence warnings from here on | |
exec >/dev/null 2>&1 | |
# Read from stdin in the background and | |
# kill running program when stdin closes | |
exec 0<&0 $( | |
while read; do :; done | |
kill -KILL $pid1 | |
) & | |
pid2=$! | |
# Clean up | |
wait $pid1 | |
ret=$? | |
kill -KILL $pid2 | |
exit $ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment