From cebf9fd6239902871fd53b67b583dbeac14146bc Mon Sep 17 00:00:00 2001 From: Michael Dombrowski Date: Thu, 11 May 2023 14:40:37 -0400 Subject: [PATCH] fix: do not close stdin except with system property --- src/main/java/com/aws/greengrass/util/Exec.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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);