From: Simon Strandgaard <0bz63fz3m1qt3001@...> Date: 2003-05-13T18:30:37+09:00 Subject: Re: RCR for child execution On Tue, 13 May 2003 18:43:28 +0900, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: RCR for child execution" > on 03/05/13, "Simon Strandgaard" <0bz63fz3m1qt3001@sneakemail.com> writes: > > |Still rb_warn and friends outputs to stderr. > |I am searching for the nice solution :-) > > Now it does. > > In message "Re: RCR for child execution" > on 03/05/13, "Simon Strandgaard" <0bz63fz3m1qt3001@sneakemail.com> writes: > > |void system(command) { > | pid=fork(); > | if(pid != 0) { > | stdout = rb_stdout; /* what im asking for */ > | stderr = rb_stderr; /* what im asking for */ > | stdin = rb_stdin; /* what im asking for */ > | execv(command); > | } > |} > | > |OK.. again assignment to stdout is illegal. freopen should be used instead. > |Admitted.. I havn't yet tried reopen'ing stdout/stderr :-) > > You misunderstand here. In current Ruby, assignment to $stdin > etc. does reopen *at the time of assignment*. Yes I know rb_stdout is a hooked variable.. this is just very simplified pseudo code. Actually I have a bug in this.. stdout is suppose to inherit rb_stdout from the parent process. So here is my example I posted earlier: void system(command) { backup_stdout = stdout; stdout = rb_stdout; pid = fork(); if(pid != 0) execv(command); stdout = backup_stdout; } Again its pseudo code :-) This is only parsing rb_stdout from parent to child... of cause also rb_stderr and rb_stdin should be parsed to the child too. -- Simon Strandgaard