From a8376d0bb870d0d1bc8a816daf044bbe7ddf6840 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Thu, 27 Apr 2006 16:22:05 +0000 Subject: Let spawner kill subprocesses, bug 119387. --- core/org.eclipse.cdt.core.linux/library/exec_pty.c | 3 +++ .../org.eclipse.cdt.core.linux/library/exec_unix.c | 3 +++ core/org.eclipse.cdt.core.linux/library/spawner.c | 26 +++++++++++++++++----- 3 files changed, 27 insertions(+), 5 deletions(-) (limited to 'core') diff --git a/core/org.eclipse.cdt.core.linux/library/exec_pty.c b/core/org.eclipse.cdt.core.linux/library/exec_pty.c index 9e484902a07..0c2c8c98fe3 100644 --- a/core/org.eclipse.cdt.core.linux/library/exec_pty.c +++ b/core/org.eclipse.cdt.core.linux/library/exec_pty.c @@ -7,6 +7,7 @@ * * Contributors: * QNX Software Systems - initial API and implementation + * Wind River Systems, Inc. *******************************************************************************/ #include "exec0.h" #include @@ -93,6 +94,8 @@ exec_pty(const char *path, char *const argv[], char *const envp[], close(fd++); } + setpgid(getpid(), getpid()); + if (envp[0] == NULL) { execv(full_path, argv); } else { diff --git a/core/org.eclipse.cdt.core.linux/library/exec_unix.c b/core/org.eclipse.cdt.core.linux/library/exec_unix.c index eb53945b89f..912b17ac278 100644 --- a/core/org.eclipse.cdt.core.linux/library/exec_unix.c +++ b/core/org.eclipse.cdt.core.linux/library/exec_unix.c @@ -7,6 +7,7 @@ * * Contributors: * QNX Software Systems - initial API and implementation + * Wind River Systems, Inc. *******************************************************************************/ #include "exec0.h" #include @@ -90,6 +91,8 @@ exec0(const char *path, char *const argv[], char *const envp[], close(fd++); } + setpgid(getpid(), getpid()); + if (envp[0] == NULL) { execv(full_path, argv); } else { diff --git a/core/org.eclipse.cdt.core.linux/library/spawner.c b/core/org.eclipse.cdt.core.linux/library/spawner.c index 21a9181e98e..2e9e1183a04 100644 --- a/core/org.eclipse.cdt.core.linux/library/spawner.c +++ b/core/org.eclipse.cdt.core.linux/library/spawner.c @@ -7,6 +7,7 @@ * * Contributors: * QNX Software Systems - initial API and implementation + * Wind River Systems, Inc. *******************************************************************************/ #include #include @@ -247,23 +248,38 @@ Java_org_eclipse_cdt_utils_spawner_Spawner_raise(JNIEnv * env, jobject jobj, switch (sig) { case 0: /* NOOP */ - status = kill(pid, 0); + status = killpg(pid, 0); + if(status == -1) { + status = kill(pid, 0); + } break; case 2: /* INTERRUPT */ - status = kill(pid, SIGINT); + status = killpg(pid, SIGINT); + if(status == -1) { + status = kill(pid, SIGINT); + } break; case 9: /* KILL */ - status = kill(pid, SIGKILL); + status = killpg(pid, SIGKILL); + if(status == -1) { + status = kill(pid, SIGKILL); + } break; case 15: /* TERM */ - status = kill(pid, SIGTERM); + status = killpg(pid, SIGTERM); + if(status == -1) { + status = kill(pid, SIGTERM); + } break; default: - status = kill(pid, sig); /* WHAT ?? */ + status = killpg(pid, sig); /* WHAT ?? */ + if(status == -1) { + status = kill(pid, sig); /* WHAT ?? */ + } break; } -- cgit v1.2.1