-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add additional guards for nix process detach #210
Conversation
Observing some weird race-condition-y behaviors where the nix.sh script previously was not reliable in rebooting systems. Most of the time with an attached TTY, the subprocess was still being killed when the TTY-attached parent shell terminated. Adding a `sync` call seems to work around the problem. Adding an explicit `disown` for linux just for completeness. It was not shown to help with the observed race condition (which is resolved by `sync`). `disown` is a bash built-in, and this is a bash script so we should be fine to use it.
bcc760b
to
9f09672
Compare
| @@ -30,7 +30,12 @@ else | |||
| timeout_min=$(($timeout/60)) | |||
| timeout_sec=$(($timeout%60)) | |||
| nohup bash -c "sleep $timeout_sec; shutdown -r +$timeout_min $message" </dev/null >/dev/null 2>&1 & | |||
| disown | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what scenario would make this necessary, but based on https://unix.stackexchange.com/a/148698 I don't believe it hurts.
| # There are some weird race conditions that might make detached jobs still die | ||
| # when this shell exits. The sync (which otherwise shouldn't do much) seems to | ||
| # eliminate them. | ||
| sync |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😕 🤷♂
|
Was it particular Linux variants that had this problem? |
|
I saw the issues on a CentOS 7 VM, on Platform9. Definite race condition-y, sometimes it worked, sometimes it didn't. Worked 100% of the time with the |
|
Thank you for your PR @reidmv :-) |
Observing some weird race-condition-y behaviors where the nix.sh script
previously was not reliable in rebooting systems. Most of the time with
an attached TTY, the subprocess was still being killed when the
TTY-attached parent shell terminated.
Adding a
synccall seems to work around the problem.Adding an explicit
disownfor linux just for completeness. It was notshown to help with the observed race condition, which is resoseems to
work around the problem.
Adding an explicit
disownfor linux just for completeness. It was notshown to help with the observed race condition (which is resolved by
sync).disownis a bash built-in, and this is a bash script so weshould be fine to use it.