From ef293fe46dfa59dd9bd1fcd3fe39d153314c8aa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Wed, 7 May 1997 07:11:56 +0200 Subject: [PATCH] Now closes the input and output pipes after dup2. Rev: lib/modules/Process.pmod:1.6 --- lib/modules/Process.pmod | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/modules/Process.pmod b/lib/modules/Process.pmod index 1c9ba6e5a1..9f18c5cc90 100644 --- a/lib/modules/Process.pmod +++ b/lib/modules/Process.pmod @@ -34,15 +34,21 @@ varargs int spawn(string s,object stdin,object stdout,object stderr) { return pid; }else{ - if(stdin) + if(stdin) { stdin->dup2(File("stdin")); + stdin->close(); + } - if(stdout) + if(stdout) { stdout->dup2(File("stdout")); + stdout->close(); + } - if(stderr) + if(stderr) { stderr->dup2(File("stderr")); - + stderr->close(); + } + ::close(); exec("/bin/sh","-c",s); exit(69); } @@ -56,6 +62,7 @@ string popen(string s) p=file::pipe(); if(!p) error("Popen failed. (couldn't create pipe)\n"); spawn(s,0,p,0); + p->close(); destruct(p); t=read(0x7fffffff); -- GitLab