From cd06b455035819e7bccab8f9e06024bbc9b7afea Mon Sep 17 00:00:00 2001 From: inglorion Date: Sat, 3 Sep 2005 12:33:11 +0000 Subject: [PATCH] Close stdin, stdout, and stderr, even if no files specified. --- detach.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/detach.c b/detach.c index a2bf5dd..c1075c7 100644 --- a/detach.c +++ b/detach.c @@ -55,8 +55,11 @@ int main(int argc, char **argv) { } if(infile) replacefd(0, infile, O_RDONLY, 0666); + else close(0); if(outfile) replacefd(1, outfile, O_WRONLY | O_CREAT | O_TRUNC, 0666); + else close(1); if(errfile) replacefd(2, errfile, O_WRONLY | O_CREAT | O_TRUNC, 0666); + else close(2); setsid(); execvp(argv[command_start], &argv[command_start]); -- 2.11.4.GIT