diff --git a/src/main/java/com/aws/greengrass/util/Exec.java b/src/main/java/com/aws/greengrass/util/Exec.java index 8b68922646..2732494728 100644 --- a/src/main/java/com/aws/greengrass/util/Exec.java +++ b/src/main/java/com/aws/greengrass/util/Exec.java @@ -315,8 +315,12 @@ public Optional exec() throws InterruptedException, IOException { } process = createProcess(); logger.debug("Created process with pid {}", getPid()); - // Close stdin, no one can write anything to stdin. - process.getOutputStream().close(); + + // By default, do not close stdin. + if ("true".equalsIgnoreCase(System.getProperty("gg.closeStdIn", "false"))) { + // Close stdin, no one can write anything to stdin. + process.getOutputStream().close(); + } stderrc = new Copier(process.getErrorStream(), stderr); stdoutc = new Copier(process.getInputStream(), stdout);