mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
appliance: Fix job control in virt-rescue.
See comment and link to busybox FAQ for explanation.
This commit is contained in:
@@ -177,6 +177,10 @@ if ! test "$guestfs_rescue" = 1; then
|
||||
else
|
||||
# Run virt-rescue shell.
|
||||
|
||||
# Get name of the serial port, from console= passed by libguestfs.
|
||||
guestfs_serial=$(grep -Eo 'console=[^[:space:]]+' /proc/cmdline |
|
||||
sed s/console=//)
|
||||
|
||||
# Remove LD_PRELOAD=libSegFault set above.
|
||||
unset LD_PRELOAD
|
||||
|
||||
@@ -185,6 +189,16 @@ else
|
||||
echo "PS1='><rescue> '" >> $HOME/.bashrc
|
||||
echo "export TERM PS1" >> $HOME/.bashrc
|
||||
|
||||
# The shell is opened by default on /dev/console, which (on Linux)
|
||||
# is not a controlling terminal, causing job control to fail. For
|
||||
# how we work around this, see:
|
||||
# https://busybox.net/FAQ.html#job_control
|
||||
run_bash_with_ctty ()
|
||||
{
|
||||
setsid bash -c \
|
||||
"exec bash </dev/$guestfs_serial >/dev/$guestfs_serial 2>&1"
|
||||
}
|
||||
|
||||
echo
|
||||
echo "------------------------------------------------------------"
|
||||
echo
|
||||
@@ -194,7 +208,7 @@ else
|
||||
echo "You have to mount the guest's partitions under /sysroot"
|
||||
echo "before you can examine them."
|
||||
echo
|
||||
bash -i
|
||||
run_bash_with_ctty
|
||||
echo
|
||||
echo "virt-rescue: Syncing the disk now before exiting ..."
|
||||
echo
|
||||
|
||||
Reference in New Issue
Block a user