diff options
author | Alyssa Ross <hi@alyssa.is> | 2022-02-19 16:37:31 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2022-02-19 16:37:31 +0000 |
commit | 9524baba518f5140167376cf07a4ab90f778fc45 (patch) | |
tree | eed719e2f3214fafbb0bd0225daab27061239767 /host | |
parent | 58204aedb6ec5a2e4e7bb79cca33eef1d672f476 (diff) | |
download | spectrum-9524baba518f5140167376cf07a4ab90f778fc45.tar spectrum-9524baba518f5140167376cf07a4ab90f778fc45.tar.gz spectrum-9524baba518f5140167376cf07a4ab90f778fc45.tar.bz2 spectrum-9524baba518f5140167376cf07a4ab90f778fc45.tar.lz spectrum-9524baba518f5140167376cf07a4ab90f778fc45.tar.xz spectrum-9524baba518f5140167376cf07a4ab90f778fc45.tar.zst spectrum-9524baba518f5140167376cf07a4ab90f778fc45.zip |
host/rootfs: vm-console: lock console
If two consoles can be open for the same pty at once, things break spectacularly, so let's try to prevent that.
Diffstat (limited to 'host')
-rwxr-xr-x | host/rootfs/usr/bin/vm-console | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/host/rootfs/usr/bin/vm-console b/host/rootfs/usr/bin/vm-console index 47a5d63..5b688af 100755 --- a/host/rootfs/usr/bin/vm-console +++ b/host/rootfs/usr/bin/vm-console @@ -7,4 +7,14 @@ backtick -E pty { ch-remote --api-socket /run/service/ext-${1}/env/cloud-hypervisor.sock info } -foot -T $1 --pty $pty +foreground { + flock -n $pty + foot -T $1 --pty $pty +} +importas -iu ? ? +foreground { + if { test $? != 230 } + fdmove -c 1 2 + printf "%s: a console for %s is already open\n" $0 $1 +} +exit $? |