Provides a shell script that restarts stage2 anaconda by killing it along with everything it has spwawned (X server, metacity). This also needs some support by the loader. --- loader/loader.c | 22 ++++++++++++------ scripts/Makefile.am | 3 ++ scripts/restart-anaconda | 55 ++++++++++++++++++++++++++++++++++++++++++++++ scripts/upd-instroot | 1 + 4 files changed, 74 insertions(+), 7 deletions(-) create mode 100755 scripts/restart-anaconda diff --git a/loader/loader.c b/loader/loader.c index 84fd116..6a701e4 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -1712,6 +1712,13 @@ void loaderUsrXHandler(int signum) { init_sig = signum; } +int restart_anaconda() { + if (access("/tmp/restart_anaconda", R_OK)) + return 0; + puts("Restarting Anaconda."); + return 1; +} + static int anaconda_trace_init(void) { #ifdef USE_MTRACE setenv("MALLOC_TRACE","/malloc",1); @@ -2336,14 +2343,15 @@ int main(int argc, char ** argv) { } printf(fmt, VERSION, getProductName()); - if (!(pid = fork())) { - if (execv(anacondaArgs[0], anacondaArgs) == -1) { - fprintf(stderr,"exec of anaconda failed: %m\n"); - doExit(1); + do { + if (!(pid = fork())) { + if (execv(anacondaArgs[0], anacondaArgs) == -1) { + fprintf(stderr,"exec of anaconda failed: %m\n"); + doExit(1); + } } - } - - waitpid(pid, &status, 0); + waitpid(pid, &status, 0); + } while (restart_anaconda()); if (!WIFEXITED(status) || (WIFEXITED(status) && WEXITSTATUS(status))) { rc = 1; diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 9ca8b1a..187d4c6 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -28,4 +28,7 @@ dist_noinst_SCRIPTS = getlangnames.py upd-bootimage upd-initrd upd-kernel \ analogdir = $(libexecdir)/$(PACKAGE_NAME) dist_analog_SCRIPTS = analog +stage2scriptsdir = $(datadir)/$(PACKAGE_NAME) +dist_stage2scripts_SCRIPTS = restart-anaconda + MAINTAINERCLEANFILES = Makefile.in diff --git a/scripts/restart-anaconda b/scripts/restart-anaconda new file mode 100755 index 0000000..aed4758 --- /dev/null +++ b/scripts/restart-anaconda @@ -0,0 +1,55 @@ +#! /bin/bash +# +# restart-anaconda: Debugging tool to restart stage2 Anaconda. +# +# Copyright (C) 2010 +# Red Hat, Inc. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +RESTART_FILE=/tmp/restart_anaconda +LOADER_PID=`cat /var/run/loader.run` +ANACONDA_PID=`cat /var/run/anaconda.pid` + +descendants() { + PID=$1 + DIRECT=`ps --ppid $PID -o pid=` + INDIRECT='' + for child in $DIRECT; do + INDIRECT+=' '`descendants $child` + done + # prepend grandchildren, we are goingt to kill them first + DESCENDANTS=$INDIRECT' '$DIRECT + echo $DESCENDANTS +} + +anaconda_descendants() { + descendants $ANACONDA_PID +} + +# this is how loader knows it should restart stuff +touch $RESTART_FILE + +# kill all anaconda descendants and anaconda itself +RESTART_VICTIMS=`anaconda_descendants` +RESTART_VICTIMS+=' '$ANACONDA_PID +echo "killing processes: " $RESTART_VICTIMS +for child in $RESTART_VICTIMS; do + kill -s KILL $child &>/dev/null +done + +# give loader some time to pick up the restart file +sleep 1 +rm -f $RESTART_FILE diff --git a/scripts/upd-instroot b/scripts/upd-instroot index 8d1d6a5..6abba39 100755 --- a/scripts/upd-instroot +++ b/scripts/upd-instroot @@ -1081,6 +1081,7 @@ cp $DEST/usr/share/anaconda/losetup-stub $DEST/usr/bin/losetup cp $DEST/usr/share/anaconda/list-harddrives-stub $DEST/usr/bin/list-harddrives cp $DEST/usr/share/anaconda/loadkeys-stub $DEST/usr/bin/loadkeys cp $DEST/usr/share/anaconda/mknod-stub $DEST/usr/bin/mknod +cp $DEST/usr/share/anaconda/restart-anaconda $DEST/usr/bin/restart-anaconda mv $DEST/usr/sbin/anaconda $DEST/usr/bin/anaconda mv $DEST/usr/$LIBDIR/python?.?/site-packages/pyanaconda/sitecustomize.py $DEST/usr/$LIBDIR/python?.?/site-packages -- 1.6.6 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list