From dc86ffee1c7f05a30a1eff63a8348a4a73659451 Mon Sep 17 00:00:00 2001 From: Stefan Zabka Date: Mon, 25 May 2020 20:31:27 +0200 Subject: Closing stdin for processes without pipe running in bg --- 02_exercise/process.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/02_exercise/process.c b/02_exercise/process.c index 0b69074..c5be8c3 100644 --- a/02_exercise/process.c +++ b/02_exercise/process.c @@ -113,6 +113,9 @@ int exec_command(process p) { dup2(p.in_fd, 0); close(p.in_fd); } + if(p.in_fd == 0 && !p.blocking) { + close(0); + } if (p.out_fd != 0) { dup2(p.out_fd, 1); -- cgit v1.2.3-54-g00ecf