fix(wifibox): correctly terminate the VM by sending SIGTERM#110
Conversation
pgj
left a comment
There was a problem hiding this comment.
Please wrap the lines in the commit message to 78 characters. Also, please use simply wifibox for the name of the script, there is no need to mention the full path (which might be different per deployment settings anyway).
|
There is a problem remaining with the patch. The "problem" is that When this happens, various debug errors are exhibited on a normal setup. Namely:
But, I'm not sure how to best solve this issue. Here's wifibox.log: |
Yes, I have noticed the same issue while experimenting with your patch and my suggested addition about the adaptive wait for forced shutdown. I think I already have a solution for that. First of all, |
Just to confirm: are you satisfied that there is no condition that the VM manager exits somehow without restarting, and we don't want to call Personally, I think it's fine to remove the call. The VM manager does not create the bridge, so it shouldn't destroy it either. |
The purpose of the VM manager is to keep the VM running until it is stopped in the expected way. This can cover unexpected crashes or even deliberate reboot issued from the console. Throughout all this time, the network interface has to be available as well. I think placing the If the VM manager is killed directly from somewhere else in the system, the VM would leave the interface behind. But
I agree! |
|
I have got some warnings from ShellCheck (by running the In sbin/wifibox line 727:
trap _kill_child SIGTERM
^-----^ SC3048 (warning): In POSIX sh, prefixing signal names with 'SIG' is undefined.
In sbin/wifibox line 738:
trap - SIGTERM
^-----^ SC3048 (warning): In POSIX sh, prefixing signal names with 'SIG' is undefined.
For more information:
https://www.shellcheck.net/wiki/SC3048 -- In POSIX sh, prefixing signal nam... |
|
I've fixed the Shellcheck warnings, and fixed three calls to |
|
Also, today I realized there is a more elegant solution to solving this bug than creating the (local) whole function for it. This patch provides the same functionality: By killing the pgid (which should? be the same as the pid of Up to you how you'd like to proceed, @pgj. I'd be fine keeping this patch as-is, or reverting all changes in the |
Thanks! Curiously, ShellCheck did not give a warning for other instances 🤷 |
I like this solution! Let us do that, and I can then test it locally. |
|
That should do it. Please test. |
|
The approach works nicely. But there is a new ShellCheck warning: |
Previously, a `kill -SIGTERM` would be requested of the daemon, which would
forward the signal to wifibox. wifibox would not forward the signal to bhyve,
which requires the signal to shutdown cleanly. Instead, wifibox now kills the
pgid of the daemon, which will kill all of the children of daemon as well.
Also call echo and tr with variables ${ECHO} and ${TR} respectively.
Also explicitly unlink the tap interface from the wifibox interface, and
consistently use subshell format, standardize indentation, and use kill -TERM
instead of kill -SIGTERM.
wifibox): correctly terminate the VM by sending SIGTERM
pgj
left a comment
There was a problem hiding this comment.
Thank you for contribution! Great work!
|
Great! With this patch and all of the others applied, Wifibox now works 100% on my system. Feel free to add it to the supported list. CPU: Core i7-4870HQ CPU @ 2.50GHz
|
- [pgj/freebsd-wifibox #107](pgj/freebsd-wifibox#107) - [pgj/freebsd-wifibox #110](pgj/freebsd-wifibox#110) - [pgj/freebsd-wifibox #114](pgj/freebsd-wifibox#114) - [pgj/freebsd-wifibox #115](pgj/freebsd-wifibox#115) - [pgj/freebsd-wifibox #117](pgj/freebsd-wifibox#117)
Previously, a
kill -SIGTERMwould be requested of the daemon, which would forward the signal to /usr/local/sbin/wifibox. /usr/local/sbin/wifibox would not forward the signal to bhyve, which requires the signal to shutdown cleanly.Also explicitly unlink the tap interface from the wifibox interface, and wait 5 seconds instead of 3 for the VM to shutdown.
Also consistently use subshells.