Skip to content

Commit

Permalink
Move VM_TYPE check into vm_shutdown_halt
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed Mar 14, 2022
1 parent a5738ff commit 1fa1d35
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,7 @@ fi

if test -n "$LOGFILE" -a -z "$RUN_SHELL" ; then
echo "logging output to $LOGFILE..."
rm -f $LOGFILE
rm -f "$LOGFILE" "$LOGFILE.pid"
touch $LOGFILE
# set start time, to be substracted for build log timestamps
STARTTIME=`perl -e 'print time()'`
Expand All @@ -1485,7 +1485,7 @@ if test -n "$LOGFILE" -a -z "$RUN_SHELL" ; then
:
elif test -n "$RUNNING_IN_VM" -o -n "$NO_TIMESTAMPS" ; then
# no additional timestamps in inner vm build system
exec 1> >(echo "LOGGING_TEE_PID=$BASHPID" > $LOGFILE.pid ; exec -a 'build logging' tee -a $LOGFILE) 2>&1
exec 1> >(echo "$BASHPID" > $LOGFILE.pid ; exec -a 'build logging' tee -a $LOGFILE) 2>&1
elif test -n "$VM_ROOT" ; then
# external run of virtualization build
exec 1> >(exec -a 'build logging' perl -e 'open(F,">>",$ARGV[0])||die("$ARGV[0]: $!\n");$|=1;select(F);$|=1;while(<STDIN>){my $p=sprintf("[%5ds] ", time()-'$STARTTIME');print STDOUT $p.$_;s/^\r//s;s/\r\n/\n/gs;print F $p.$_}' $LOGFILE) 2>&1
Expand Down
5 changes: 3 additions & 2 deletions build-vm
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ vm_shutdown_halt_helper() {
}

vm_shutdown_halt() {
test "$VM_TYPE" = lxc -o "$VM_TYPE" = docker -o "$VM_TYPE" = nspawn && exit $1
# shutdown from fresh shell to close out deleted inodes
exec -a "build: halt" -- $BASH -c "$(declare -f vm_shutdown_halt_helper); vm_shutdown_halt_helper $1"
echo "Warning: clean shut down of the VM didn't work"
Expand All @@ -348,10 +349,10 @@ vm_shutdown() {
swapoff "$VM_SWAP" 2>/dev/null
echo -n "BUILDSTATUS$1" >"$VM_SWAP"
fi
test "$VM_TYPE" = lxc -o "$VM_TYPE" = docker -o "$VM_TYPE" = nspawn && exit $1

# Wait for logging tee to finish
test -f "$LOGFILE.pid" && . "$LOGFILE.pid"
LOGGING_TEE_PID=
test -f "$LOGFILE.pid" -a ! -L "$LOGFILE.pid" && read LOGGING_TEE_PID < "$LOGFILE.pid"
if test -n "$LOGGING_TEE_PID"; then
while kill -0 "$LOGGING_TEE_PID" 2>/dev/null; do
sleep 0.1
Expand Down

0 comments on commit 1fa1d35

Please sign in to comment.