Hi all,
Ruby 1.8.1
Windows 2000
For the next release of win32-process, I’m getting rid of the toplevel
Win32 module/namespace. Thus, you can do “Process.fork” instead of
"Win32::Process.fork". However, I would like to be able to just do
"fork" (no ‘Process’) in the same manner that you can on *nix. In
pure Ruby I would do something like this:
module Process
def fork
puts "fork!"
end
end
class Object
include Process
end
fork # -> “fork!”
I can’t get this to work on the C side, however. I tried this at the
end of “Init_process()”:
rb_include_module(rb_cObject,rb_mProcess);
But, it didn’t seem to work. What am I not seeing?
Regards,
Dan
/* Full Init_process() */
void Init_process()
{
child_pids = rb_ary_new();
/* Does platform support CreateRemoteThread? */
os_supported = crt_supported();
fname = rb_gv_get("$0");
path = rb_file_s_expand_path(1, &fname);
/* Classes */
cProcessError = rb_define_class_under(rb_mProcess,“Win32::ProcessError”,
rb_eRuntimeError);
/* Constants */
rb_define_const(rb_mProcess,“VERSION”,rb_str_new2(WIN32_PROCESS_VERSION));
/* Class Methods */
rb_define_singleton_method(rb_mProcess,“kill”,process_kill,-1);
rb_define_singleton_method(rb_mProcess,“fork”, process_fork, 0);
rb_define_singleton_method(rb_mProcess,“wait”, process_wait, 0);
rb_define_singleton_method(rb_mProcess,“wait2”, process_wait2, 0);
rb_define_singleton_method(rb_mProcess,“waitpid”, process_waitpid,
-1);
rb_define_singleton_method(rb_mProcess,“waitpid2”,
process_waitpid2, -1);
// Doesn’t work
rb_include_module(rb_cObject,rb_mProcess);
}