Skip to content
Snippets Groups Projects
Commit ef293fe4 authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

Now closes the input and output pipes after dup2.

Rev: lib/modules/Process.pmod:1.6
parent f7ad751f
No related branches found
No related tags found
No related merge requests found
...@@ -34,15 +34,21 @@ varargs int spawn(string s,object stdin,object stdout,object stderr) ...@@ -34,15 +34,21 @@ varargs int spawn(string s,object stdin,object stdout,object stderr)
{ {
return pid; return pid;
}else{ }else{
if(stdin) if(stdin) {
stdin->dup2(File("stdin")); stdin->dup2(File("stdin"));
stdin->close();
}
if(stdout) if(stdout) {
stdout->dup2(File("stdout")); stdout->dup2(File("stdout"));
stdout->close();
}
if(stderr) if(stderr) {
stderr->dup2(File("stderr")); stderr->dup2(File("stderr"));
stderr->close();
}
::close();
exec("/bin/sh","-c",s); exec("/bin/sh","-c",s);
exit(69); exit(69);
} }
...@@ -56,6 +62,7 @@ string popen(string s) ...@@ -56,6 +62,7 @@ string popen(string s)
p=file::pipe(); p=file::pipe();
if(!p) error("Popen failed. (couldn't create pipe)\n"); if(!p) error("Popen failed. (couldn't create pipe)\n");
spawn(s,0,p,0); spawn(s,0,p,0);
p->close();
destruct(p); destruct(p);
t=read(0x7fffffff); t=read(0x7fffffff);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment