• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 30622595516

31 Jul 2026 10:10AM UTC coverage: 72.527% (-0.1%) from 72.641%
30622595516

Pull #2239

github

web-flow
Merge b76ccb249 into 468118d46
Pull Request #2239: #218: add possibility to start a command in a new window with the process builder

5048 of 7697 branches covered (65.58%)

Branch coverage included in aggregate %.

13123 of 17357 relevant lines covered (75.61%)

3.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.43
cli/src/main/java/com/devonfw/tools/ide/process/ProcessMode.java
1
package com.devonfw.tools.ide.process;
2

3
import java.lang.ProcessBuilder.Redirect;
4

5
/**
6
 * The ProcessMode defines how to start the command process and how output streams are handled using {@link ProcessBuilder}. Modes that can be used:
7
 * {@link #BACKGROUND} {@link #BACKGROUND_SILENT} {@link #BACKGROUND_NEW_WINDOW} {@link #DEFAULT} {@link #DEFAULT_CAPTURE}
8
 */
9
public enum ProcessMode {
3✔
10
  /**
11
   * The process of the command will be run like a background process. Technically the parent process will simply not await its child process and a shell is
12
   * used to start the process. The parent process will get the output of the child process using {@link ProcessBuilder.Redirect#INHERIT}. In Unix systems the
13
   * equivalent of appending an '& disown' is used to detach the subprocess from its parent process. In Unix terms, the shell will not send a SIGHUP signal but
14
   * the process remains connected to the terminal so that output is still received. (Only '&' is not used because it just removes awaiting but not sending of
15
   * SIGHUP. Using nohup would simply result in redirecting output to a nohup.out file.)
16
   */
17
  BACKGROUND {
11✔
18
    @Override
19
    public Redirect getRedirectOutput() {
20
      return Redirect.INHERIT;
2✔
21
    }
22

23
    @Override
24
    public Redirect getRedirectError() {
25
      return Redirect.INHERIT;
2✔
26
    }
27

28
    @Override
29
    public Redirect getRedirectInput() {
30
      return null;
2✔
31
    }
32
  },
33
  /**
34
   * Like {@link #BACKGROUND}. Instead of redirecting the output to the parent process, the output is redirected to the 'null file' using
35
   * {@link ProcessBuilder.Redirect#DISCARD}.
36
   */
37
  BACKGROUND_SILENT {
11✔
38
    @Override
39
    public Redirect getRedirectOutput() {
40
      return Redirect.DISCARD;
2✔
41
    }
42

43
    @Override
44
    public Redirect getRedirectError() {
45
      return Redirect.DISCARD;
2✔
46
    }
47

48
    @Override
49
    public Redirect getRedirectInput() {
50
      return null;
2✔
51
    }
52
  },
53
  /**
54
   * Like {@link #BACKGROUND_SILENT} but opens a new terminal window for the process. The new window captures the subprocess output and error streams, so they
55
   * are discarded from the parent process perspective using {@link ProcessBuilder.Redirect#DISCARD}. The parent process does not wait for the child and the
56
   * child survives if the parent terminates.
57
   */
58
  BACKGROUND_NEW_WINDOW {
11✔
59
    @Override
60
    public Redirect getRedirectOutput() {
61
      return Redirect.DISCARD;
2✔
62
    }
63

64
    @Override
65
    public Redirect getRedirectError() {
66
      return Redirect.DISCARD;
2✔
67
    }
68

69
    @Override
70
    public Redirect getRedirectInput() {
71
      return null;
2✔
72
    }
73
  },
74
  /**
75
   * The process will be started according {@link ProcessBuilder.Redirect#INHERIT} without any detaching of parent process and child process. This setting makes
76
   * the child process dependant from the parent process! (If you close the parent process the child process will also be terminated.)
77
   */
78
  DEFAULT {
11✔
79
    @Override
80
    public Redirect getRedirectOutput() {
81
      return Redirect.INHERIT;
2✔
82
    }
83

84
    @Override
85
    public Redirect getRedirectError() {
86
      return Redirect.INHERIT;
2✔
87
    }
88

89
    @Override
90
    public Redirect getRedirectInput() {
91
      return Redirect.INHERIT;
2✔
92
    }
93

94
  },
95
  /**
96
   * The process will be started according {@link ProcessBuilder.Redirect#PIPE} and the standard output and standard error streams will be captured from the
97
   * parent process. In other words, they will be printed in the console of the parent process. This setting makes the child process dependant from the parent
98
   * process! (If you close the parent process the child process will also be terminated.)
99
   */
100
  DEFAULT_CAPTURE {
11✔
101
    @Override
102
    public Redirect getRedirectOutput() {
103
      return Redirect.PIPE;
2✔
104
    }
105

106
    @Override
107
    public Redirect getRedirectError() {
108
      return Redirect.PIPE;
2✔
109
    }
110

111
    @Override
112
    public Redirect getRedirectInput() {
113
      return null;
2✔
114
    }
115

116
  },
117

118
  /**
119
   * Like {@link #DEFAULT} the parent and child process will not be detached, the subprocess output will be discarded (to the operating system "null file" )
120
   * using {@link ProcessBuilder.Redirect#DISCARD}.
121
   */
122
  DEFAULT_SILENT {
11✔
123
    @Override
124
    public Redirect getRedirectOutput() {
125

126
      return Redirect.DISCARD;
×
127
    }
128

129
    @Override
130
    public Redirect getRedirectError() {
131

132
      return Redirect.DISCARD;
×
133
    }
134

135
    @Override
136
    public Redirect getRedirectInput() {
137

138
      return Redirect.INHERIT;
×
139
    }
140
  };
141

142
  /**
143
   * Method to return the {@link ProcessBuilder.Redirect} strategy for the standard output stream of the process. Depending on the mode, the output may be
144
   * inherited from the parent process, discarded, or piped for programmatic access.
145
   *
146
   * @return the {@link ProcessBuilder.Redirect} configuration for standard output, or {@code null} if no redirection is specified.
147
   */
148
  public abstract Redirect getRedirectOutput();
149

150
  /**
151
   * Method to return the {@link ProcessBuilder.Redirect} strategy for the standard error stream of the process. Depending on the mode, the error output may be
152
   * inherited from the parent process, discarded, or piped for programmatic access.
153
   *
154
   * @return the {@link ProcessBuilder.Redirect} configuration for standard error, or {@code null} if no redirection is specified.
155
   */
156
  public abstract Redirect getRedirectError();
157

158
  /**
159
   * Method to return the {@link ProcessBuilder.Redirect} strategy for the standard input stream of the process. Depending on the mode, the input may be
160
   * inherited from the parent process or left unconfigured.
161
   *
162
   * @return the {@link ProcessBuilder.Redirect} configuration for standard input, or {@code null} if no redirection is specified.
163
   */
164
  public abstract Redirect getRedirectInput();
165

166
  /**
167
   * Method to check if the ProcessMode is a background process.
168
   *
169
   * @return {@code true} if the {@link ProcessMode} is {@link ProcessMode#BACKGROUND}, {@link ProcessMode#BACKGROUND_SILENT}, or
170
   *     {@link ProcessMode#BACKGROUND_NEW_WINDOW}, {@code false} if not.
171
   */
172
  public boolean isBackground() {
173

174
    return this == BACKGROUND || this == BACKGROUND_SILENT || this == BACKGROUND_NEW_WINDOW;
13✔
175
  }
176

177
  /**
178
   * Method to check if the ProcessMode should launch the process in a new terminal window.
179
   *
180
   * @return {@code true} if this mode should launch the process in a new terminal window, {@code false} otherwise.
181
   */
182
  public boolean launchesNewWindow() {
183

184
    return this == BACKGROUND_NEW_WINDOW;
7✔
185
  }
186

187
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc