Using bhyvectl --destroy In a Script reddit / freebsd ---------------------------------------------------------------------- bawdyanarchist · 2022-01-04 23:30 I am trying to `bhyvectl --force-poweroff ; bhyvectl --destroy` in a script. However, the behavior that I get in my xterm isn't ideal. The script continues running, and even continues past `read` commands. Meanwhile for about 10 seconds, I get repeated printing of the xterm prompt. For example: `root@mymachine:~ #` `root@mymachine:~ #` `root@mymachine:~ #` `root@mymachine:~ #` `...` I need the `bhyvectl --destroy` command to finish running before continuing, but I can't seem to find a way to make this happen. I tried sending the process to the background with `&`. I also tried: `csh -c 'bhyvectl --vm=usbvm --force-poweroff ; bhyvectl --vm=usbvm --destroy' &` If I launch a new xterm with: `xterm -e csh -c 'bhyvectl --vm=usbvm --force-poweroff ; bhyvectl --vm=usbvm --destroy; /bin/csh` That actually does work. However, I need this script to be generalizable to people who might not be running X. What can I do to cause bhyvectl to play inside of scripts properly? *EDIT: So I ran this from a different TTY console (X non running on that TTY), and everything ran fine. So this appears to be a problem specifically running the command in xterm* ---------------------------------------------------------------------- [deleted] · 2022-01-05 03:39 [deleted] ---------------------------------------------------------------------- bawdyanarchist · 2022-01-05 17:15 I'm not sure why they deleted their comment here, but they posted this thread yesterday. It was the solution I was looking for. Basically avoids using `bhyvectl --destroy` entirely. I was having problems using `bhyvectl --force-poweroff` when trying to re-boot a VM, but using `pkill -f "bhyve: my_vm"` seems to be fine, and a much more graceful way of doing it. https://forums.freebsd.org/threads/graceful-shutdown-of-bhyve- guests.80979/#post-518532