1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.exec.issues;
19
20 import java.io.IOException;
21 import java.util.concurrent.TimeUnit;
22
23 import org.apache.commons.exec.AbstractExecTest;
24 import org.apache.commons.exec.CommandLine;
25 import org.apache.commons.exec.DefaultExecutor;
26 import org.apache.commons.exec.OS;
27 import org.apache.commons.exec.PumpStreamHandler;
28 import org.junit.jupiter.api.Disabled;
29 import org.junit.jupiter.api.Test;
30 import org.junit.jupiter.api.Timeout;
31
32
33
34
35 public class Exec57Test extends AbstractExecTest {
36
37
38
39
40
41
42
43
44
45 @Disabled("Broken for Unix-based systems")
46 @Test
47 @Timeout(value = TEST_TIMEOUT, unit = TimeUnit.MILLISECONDS)
48 public void testExecutionOfBackgroundProcess() throws IOException {
49
50 final CommandLine cmdLine = new CommandLine("sh").addArgument("-c").addArgument("./src/test/scripts/issues/exec-57-nohup.sh", false);
51 final DefaultExecutor executor = DefaultExecutor.builder().get();
52 final PumpStreamHandler pumpStreamHandler = new PumpStreamHandler(System.out, System.err);
53
54 executor.setStreamHandler(pumpStreamHandler);
55
56 executor.execute(cmdLine);
57 }
58
59
60
61
62
63
64 @Test
65 @Timeout(value = TEST_TIMEOUT, unit = TimeUnit.MILLISECONDS)
66 public void testExecutionOfDetachedProcess() throws IOException {
67
68 if (!OS.isFamilyUnix()) {
69 testNotSupportedForCurrentOperatingSystem();
70 return;
71 }
72
73 final CommandLine cmdLine = new CommandLine("sh").addArgument("-c").addArgument("./src/test/scripts/issues/exec-57-detached.sh", false);
74 final DefaultExecutor executor = DefaultExecutor.builder().get();
75 final PumpStreamHandler pumpStreamHandler = new PumpStreamHandler(System.out, System.err);
76
77 executor.setStreamHandler(pumpStreamHandler);
78
79 executor.execute(cmdLine);
80 }
81 }