com pftt2: close #29, Exit status is not being respected in exec methods: src/com/mostc/pftt/host/LocalHost.java
src/com/mostc/pftt/util/HostEnvUtil.java
| From: | Christoph Michael Becker | Date: | Tue, 13 Aug 2019 07:05:31 +0000 |
| Subject: | com pftt2: close #29, Exit status is not being respected in exec methods: src/com/mostc/pftt/host/LocalHost.java src/com/mostc/pftt/util/HostEnvUtil.java |
||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-68631@lists.php.net to get a copy of this message | ||
Commit: 61f397741eede36bdc9db03e8bedf4c1f436ec05
Author: Holly Li (WIPRO LIMITED) <v-huli4@microsoft.com> Tue, 13 Aug 2019 08:37:45
+0200
Committer: Christoph M. Becker <cmbecker69@gmx.de> Tue, 13 Aug 2019 09:05:31 +0200
Parents: 260bd899bc0306426dc3d0c7f4348990c6d636db
Branches: master
Link: http://git.php.net/?p=pftt2.git;a=commitdiff;h=61f397741eede36bdc9db03e8bedf4c1f436ec05
Log:
close #29, Exit status is not being respected in exec methods
Bugs:
https://bugs.php.net/29
Changed paths:
M src/com/mostc/pftt/host/LocalHost..java
M src/com/mostc/pftt/util/HostEnvUtil.java
Diff:
diff --git a/src/com/mostc/pftt/host/LocalHost.java b/src/com/mostc/pftt/host/LocalHost.java
index 2c8fe64..e018c66 100644
--- a/src/com/mostc/pftt/host/LocalHost.java
+++ b/src/com/mostc/pftt/host/LocalHost.java
@@ -505,6 +505,14 @@ public abstract class LocalHost extends AHost {
}
}*/
//
+
+ // try to set exit code after execution
+ try {
+ exit_code = p.exitValue();
+ } catch (IllegalThreadStateException ex )
+ {
+ ConsoleManagerUtil.printStackTrace(LocalHost.class, ex);
+ }
active_proc_counter.decrementAndGet();
diff --git a/src/com/mostc/pftt/util/HostEnvUtil.java b/src/com/mostc/pftt/util/HostEnvUtil.java
index 99985ff..4a856a9 100644
--- a/src/com/mostc/pftt/util/HostEnvUtil.java
+++ b/src/com/mostc/pftt/util/HostEnvUtil.java
@@ -669,11 +669,10 @@ public final class HostEnvUtil {
private static void addRuleToFirewall(ConsoleManager cm, AHost host, String name, String
installerFile) throws IOException, Exception {
String rule = name.replace(' ', '_');
- ExecOutput op = host.execOut("cmd /c powershell -Command \"if ($(Get-NetFirewallRule
-DisplayName '"+ rule + "')) {echo 'found'} else { echo 'not
found' }\" 2>nul", AHost.TEN_MINUTES);
+ ExecOutput op = host.execOut("netsh advfirewall firewall show rule name=" + rule,
AHost.ONE_MINUTE);
// Check if rule exists for file, if not add it
- // TODO: Adjust to use exit status, but have to figure out why java overwrites status code.
- if(op.output.contains("not found")) {
+ if(op.exit_code != 0) {
cm.println(EPrintType.IN_PROGRESS, HostEnvUtil.class, "Adding " + name + " as
rule for the firewall...");
host.execElevated(cm, HostEnvUtil.class, "netsh advfirewall firewall add rule name=" +
rule + " dir=in action=allow "
+ "program=\""+ installerFile +"\" enable=yes
remoteip=127.0.0.1", AHost.ONE_MINUTE);