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

devonfw / IDEasy / 15182675589

22 May 2025 09:11AM UTC coverage: 67.713% (-0.003%) from 67.716%
15182675589

Pull #1330

github

web-flow
Merge 688f0e965 into f34447afb
Pull Request #1330: #1306 Redirect cleaned up in ProcessContext and ProcessMode

3119 of 5016 branches covered (62.18%)

Branch coverage included in aggregate %.

8030 of 11449 relevant lines covered (70.14%)

3.07 hits per line

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

80.77
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 #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
    public Redirect getRedirectOutput() {
19
      return Redirect.INHERIT;
2✔
20
    }
21

22
    public Redirect getRedirectError() {
23
      return Redirect.INHERIT;
2✔
24
    }
25
  },
26
  /**
27
   * Like {@link #BACKGROUND}. Instead of redirecting the output to the parent process, the output is redirected to the 'null file' using
28
   * {@link ProcessBuilder.Redirect#DISCARD}.
29
   */
30
  BACKGROUND_SILENT {
11✔
31
    public Redirect getRedirectOutput() {
32
      return Redirect.DISCARD;
2✔
33
    }
34

35
    public Redirect getRedirectError() {
36
      return Redirect.DISCARD;
2✔
37
    }
38
  },
39
  /**
40
   * The process will be started according {@link ProcessBuilder.Redirect#INHERIT} without any detaching of parent process and child process. This setting makes
41
   * the child process dependant from the parent process! (If you close the parent process the child process will also be terminated.)
42
   */
43
  DEFAULT {
11✔
44
    public Redirect getRedirectOutput() {
45
      return Redirect.INHERIT;
2✔
46
    }
47

48
    public Redirect getRedirectError() {
49
      return Redirect.INHERIT;
2✔
50
    }
51

52
    public Redirect getRedirectInput() {
53
      return Redirect.INHERIT;
2✔
54
    }
55

56
  },
57
  /**
58
   * The process will be started according {@link ProcessBuilder.Redirect#PIPE} and the standard output and standard error streams will be captured from the
59
   * 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
60
   * process! (If you close the parent process the child process will also be terminated.)
61
   */
62
  DEFAULT_CAPTURE {
11✔
63
    public Redirect getRedirectOutput() {
64
      return Redirect.PIPE;
2✔
65
    }
66

67
    public Redirect getRedirectError() {
68
      return Redirect.PIPE;
2✔
69
    }
70

71
  },
72

73
  /**
74
   * Like {@link #DEFAULT} the parent and child process will not be detached, the subprocess output will be discarded (to the operating system "null file" )
75
   * using {@link ProcessBuilder.Redirect#DISCARD}.
76
   */
77
  DEFAULT_SILENT {
11✔
78
    public Redirect getRedirectOutput() {
79
      return Redirect.DISCARD;
×
80
    }
81

82
    public Redirect getRedirectError() {
83
      return Redirect.DISCARD;
×
84
    }
85

86
    public Redirect getRedirectInput() {
87
      return Redirect.INHERIT;
×
88
    }
89
  };
90

91

92
  public Redirect getRedirectOutput() {
93
    return null;
×
94
  }
95

96
  public Redirect getRedirectError() {
97
    return null;
×
98
  }
99

100
  public Redirect getRedirectInput() {
101
    return null;
2✔
102
  }
103

104

105
  /**
106
   * Method to check if the ProcessMode is a background process.
107
   *
108
   * @return {@code true} if the {@link ProcessMode} is {@link ProcessMode#BACKGROUND} or {@link ProcessMode#BACKGROUND_SILENT}, {@code false} if not.
109
   */
110
  public boolean isBackground() {
111

112
    return this == BACKGROUND || this == BACKGROUND_SILENT;
10✔
113
  }
114

115
  // TODO ADD EXTERNAL_WINDOW_MODE IN FUTURE Issue: https://github.com/devonfw/IDEasy/issues/218
116

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

© 2026 Coveralls, Inc