Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Ferrazzutti2015-04-30 21:40:30 +0000
committerAlexander Kurtakov2015-05-04 06:41:26 +0000
commit29fbe077e05f4044bdd245f981920920222c4f0f (patch)
tree00678e5434602c82b2df5de33f7a3b6314922536
parentb4532560b3909515da5ff1fbe5e9ec80e0043358 (diff)
downloadorg.eclipse.linuxtools-29fbe077e05f4044bdd245f981920920222c4f0f.tar.gz
org.eclipse.linuxtools-29fbe077e05f4044bdd245f981920920222c4f0f.tar.xz
org.eclipse.linuxtools-29fbe077e05f4044bdd245f981920920222c4f0f.zip
Systemtap: terminate parser processes on stop.
When a Parser job is cancelled, terminate the underlying stap process whether it is a local or remote process. Consequently, cause any process run remotely by means of execRemote to be terminated when its Jsch session is closed. Change-Id: Ibd4d3a04069cf30086a78985f02dad72e8782c60 Signed-off-by: Andrew Ferrazzutti <aferrazz@redhat.com> Reviewed-on: https://git.eclipse.org/r/46940 Tested-by: Hudson CI Reviewed-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--profiling/org.eclipse.linuxtools.tools.launch.core/META-INF/MANIFEST.MF2
-rw-r--r--profiling/org.eclipse.linuxtools.tools.launch.core/pom.xml2
-rw-r--r--profiling/org.eclipse.linuxtools.tools.launch.core/src/org/eclipse/linuxtools/tools/launch/core/factory/LinuxtoolsProcessFactory.java21
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/tparsers/ProbeParser.java6
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/tparsers/TapsetParser.java11
5 files changed, 32 insertions, 10 deletions
diff --git a/profiling/org.eclipse.linuxtools.tools.launch.core/META-INF/MANIFEST.MF b/profiling/org.eclipse.linuxtools.tools.launch.core/META-INF/MANIFEST.MF
index 09cbf124d4..691777286b 100644
--- a/profiling/org.eclipse.linuxtools.tools.launch.core/META-INF/MANIFEST.MF
+++ b/profiling/org.eclipse.linuxtools.tools.launch.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %bundleName
Bundle-SymbolicName: org.eclipse.linuxtools.tools.launch.core;singleton:=true
-Bundle-Version: 3.1.0.qualifier
+Bundle-Version: 3.2.0.qualifier
Bundle-Vendor: %provider
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime,
diff --git a/profiling/org.eclipse.linuxtools.tools.launch.core/pom.xml b/profiling/org.eclipse.linuxtools.tools.launch.core/pom.xml
index eec5f853c3..a03823601c 100644
--- a/profiling/org.eclipse.linuxtools.tools.launch.core/pom.xml
+++ b/profiling/org.eclipse.linuxtools.tools.launch.core/pom.xml
@@ -18,7 +18,7 @@
</parent>
<artifactId>org.eclipse.linuxtools.tools.launch.core</artifactId>
- <version>3.1.0-SNAPSHOT</version>
+ <version>3.2.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>Linux Tools Tools Launcher Core Plug-in</name>
diff --git a/profiling/org.eclipse.linuxtools.tools.launch.core/src/org/eclipse/linuxtools/tools/launch/core/factory/LinuxtoolsProcessFactory.java b/profiling/org.eclipse.linuxtools.tools.launch.core/src/org/eclipse/linuxtools/tools/launch/core/factory/LinuxtoolsProcessFactory.java
index f1c47037c9..caa834b986 100644
--- a/profiling/org.eclipse.linuxtools.tools.launch.core/src/org/eclipse/linuxtools/tools/launch/core/factory/LinuxtoolsProcessFactory.java
+++ b/profiling/org.eclipse.linuxtools.tools.launch.core/src/org/eclipse/linuxtools/tools/launch/core/factory/LinuxtoolsProcessFactory.java
@@ -186,6 +186,7 @@ public abstract class LinuxtoolsProcessFactory {
}
ChannelExec channel = (ChannelExec) session.openChannel("exec"); //$NON-NLS-1$
+ channel.setPty(true);
channel.setCommand(command.toString());
channel.setInputStream(null, true);
channel.setOutputStream(out, true);
@@ -250,4 +251,24 @@ public abstract class LinuxtoolsProcessFactory {
return channel;
}
+
+ /**
+ * Convenience method: asks the channel to attempt termination of the
+ * currently-running process on the channel's session.
+ * @param channel The channel whose session process should be terminated.
+ * @return <code>true</code> on a successul attempt of terminating the process,
+ * <code>false</code> otherwise.
+ * @since 3.2
+ */
+ public static boolean terminateProcess(Channel channel) {
+ try {
+ OutputStream out = channel.getOutputStream();
+ out.write(3);
+ out.flush();
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/tparsers/ProbeParser.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/tparsers/ProbeParser.java
index 0fc35ae0bb..9ea1c09ab9 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/tparsers/ProbeParser.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/tparsers/ProbeParser.java
@@ -179,11 +179,9 @@ public final class ProbeParser extends TreeTapsetParser {
return false;
}
// Check just the first probe printed
- int end = probeDump.indexOf('\n');
- if (end != -1) {
- probeDump = probeDump.substring(0, end);
+ try (Scanner scanner = new Scanner(probeDump)) {
+ return Pattern.matches(PROBE_FORM_CHECK_REGEX, scanner.nextLine());
}
- return Pattern.matches(PROBE_FORM_CHECK_REGEX, probeDump);
}
/**
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/tparsers/TapsetParser.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/tparsers/TapsetParser.java
index f0727afef6..dca42d4fc2 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/tparsers/TapsetParser.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/tparsers/TapsetParser.java
@@ -149,8 +149,6 @@ public abstract class TapsetParser extends Job {
if (!remote) {
try {
return runLocalStap(args, getErrors);
- } catch (InterruptedException e) {
- return ""; //$NON-NLS-1$
} catch (IOException e) {
return null;
}
@@ -173,7 +171,7 @@ public abstract class TapsetParser extends Job {
return IStatus.OK;
}
- private String runLocalStap(String[] args, boolean getErrors) throws IOException, InterruptedException {
+ private String runLocalStap(String[] args, boolean getErrors) throws IOException {
Process process = RuntimeProcessFactory.getFactory().exec(
args, EnvironmentVariablesPreferencePage.getEnvironmentVariables(), null);
// An IOException should be thrown if there's a problem with exec, but to cover possible error
@@ -189,7 +187,11 @@ public abstract class TapsetParser extends Job {
egobbler = new StringStreamGobbler(process.getErrorStream());
egobbler.start();
}
- process.waitFor();
+ try {
+ process.waitFor();
+ } catch (InterruptedException e) {
+ process.destroy();
+ }
gobbler.stop();
if (egobbler == null) {
return gobbler.getOutput().toString();
@@ -234,6 +236,7 @@ public abstract class TapsetParser extends Job {
return null;
}
channel.getSession().disconnect();
+ channel.disconnect();
return (!getErrors ? str : strErr).toString();
}

Back to the top