From: ts Date: 2003-05-10T02:04:12+09:00 Subject: Re: extern "C" of prep_stdio >>>>> "a" == ahoward writes: a> now, i personally have had much better luck using #reopen, but i'm curious as a> to your rational. No rational, pigeon% cat a.c #include int main() { int pipes[2], count; VALUE params[2], w; char str[512]; FILE *fd; if ((fd = fopen("aaa", "w")) == NULL) { exit(1); } if (pipe(pipes) == -1) { exit(1); } ruby_init(); ruby_init_loadpath(); params[0] = INT2FIX(pipes[1]); params[1] = rb_str_new2("w"); w = rb_class_new_instance(2, params, rb_path2class("IO")); rb_funcall(rb_defout, rb_intern("reopen"), 1, w); rb_funcall(rb_stderr, rb_intern("reopen"), 1, w); rb_eval_string("$stderr.puts 'aa'; puts 'hello'; system('ls a.c xx')"); count = read(pipes[0], str, 512); if (count >= 0) { fprintf(fd, "<<\n%*.*s>>\n", count, count, str); } fclose(fd); return 0; } pigeon% pigeon% a.out pigeon% pigeon% cat aaa << aa hello ls: xx: No such file or directory a.c >> pigeon% Guy Decoux