[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[master 3/3] shutdown: kill processes in the anaconda process group.
- From: Ales Kozumplik <akozumpl redhat com>
- To: anaconda-devel-list redhat com
- Subject: [master 3/3] shutdown: kill processes in the anaconda process group.
- Date: Tue, 22 Mar 2011 18:42:41 +0100
Previously killall5 omitted the init's session (which includes the anaconda
process group) and anaconda and everything spawned from there (including
the vnc server) survived both the killall5 calls.
Related: rhbz#679397
---
loader/init.c | 2 --
loader/loader.c | 3 +++
loader/shutdown.c | 22 ++++++++++++++++++++--
3 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/loader/init.c b/loader/init.c
index 9c193b4..65df89c 100644
--- a/loader/init.c
+++ b/loader/init.c
@@ -827,8 +827,6 @@ int main(int argc, char **argv) {
printf("running install...\n");
- setsid();
-
if (!(installpid = fork())) {
/* child */
*argvp++ = "/sbin/loader";
diff --git a/loader/loader.c b/loader/loader.c
index aac816e..d4437c3 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -2393,6 +2393,9 @@ int main(int argc, char ** argv) {
do {
if (!(pid = fork())) {
+ /* Create a new process group that we can easily kill off later. */
+ setpgid(0, 0);
+ /* This is where the Anaconda python process is started. */
if (execv(anacondaArgs[0], anacondaArgs) == -1) {
fprintf(stderr,"exec of anaconda failed: %m\n");
doExit(1);
diff --git a/loader/shutdown.c b/loader/shutdown.c
index bb32359..8535a1b 100644
--- a/loader/shutdown.c
+++ b/loader/shutdown.c
@@ -38,11 +38,27 @@ void disableSwap(void);
void unmountFilesystems(void);
static void performTerminations(void) {
+ /* First of all kill everything in the anaconda process group. This won't
+ hit any daemons spawned from anaconda, those usually call setsid(). */
+ char buf[256];
+ int fd, anaconda_pid = 0;
+ if ((fd = open("/var/run/anaconda.pid", O_RDONLY)) >= 0 ) {
+ if (read(fd, buf, 256) > 0) {
+ anaconda_pid = atol(buf);
+ }
+ }
+ if (anaconda_pid > 0) {
+ printf("terminating anaconda...");
+ kill(-anaconda_pid, SIGTERM);
+ printf("done\n");
+ }
+
+ /* Next, kill everything except what is inside the init's session or
+ excluded in donotkill. */
FILE *f;
char *donotkill[] = {"mdmon", "NetworkManager", "dhclient", NULL};
- char buf[256], omit[256], oarg[64];
+ char omit[256], oarg[64];
char **procname, *pid;
-
/* find some pids so we can omit them from killall5 */
*omit = '\0';
for (procname=donotkill; *procname; procname++) {
@@ -64,12 +80,14 @@ static void performTerminations(void) {
sync();
printf("sending termination signals...");
+ fflush(stdout);
sprintf(buf, "/sbin/killall5 -15%s", omit);
system(buf);
sleep(2);
printf("done\n");
printf("sending kill signals...");
+ fflush(stdout);
sprintf(buf, "/sbin/killall5 -9%s", omit);
system(buf);
sleep(2);
--
1.7.3.3
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]