From: Simon Strandgaard <0bz63fz3m1qt3001@...> Date: 2003-05-13T03:04:01+09:00 Subject: Re: RCR for child execution On Mon, 12 May 2003 17:21:25 +0000, ahoward wrote: > On Mon, 12 May 2003, Simon Strandgaard wrote: > >> Using system or backquote, then it goes BOOM. The problem as I see it is >> localized in Rubys code - not mine! Ruby spawns a child which inherits >> stdout/stderr. This child should instead inherit rb_stdout/rb_stderr >> instead!!! Can this issue be fixed on Ruby ??? > > this is not correct thinking. ;-) Me having installed Human Brain 0.3 alpha. [snip filedescriptors] Yes I know that fork() doesn't take an explicit argument where you can specify which stdout/stderr the child should inherit. But this can be accomplished by a small hack. void system(command) { backup_stdout = stdout; stdout = rb_stdout; pid = fork(); if(pid != 0) { execv(command); stdout = backup_stdout; } Assignment to stdout/stderr is not legal.. of couse reopen should be used. [snip example] Thanks for your fine example.. But it won't work!! I am sharing a bunch of classes between C++ and Ruby, within the same thread. Your code is 2 differnt processes! I don't want to marshall all my classes via a pipe between C++ and Ruby. -- Simon Strandgaard