win32utils-devel@rubyforge.org
2004-Feb-15 17:50 UTC
[Win32utils-devel] Win32::Process fork fragility
Park,
I was just playing around with the Process.fork/wait that you committed. I
discovered that it''s rather easy to break with this:
require "win32/process"
include Win32
Dir.chdir ".." # This causes the problem
pid = Win32::Process.fork
if pid == 0
puts "In the child"
exit
else
puts "In the parent"
end
Win32::Process.wait(pid)
I think the problem lies in this code:
fname = rb_gv_get("$0");
...
path = rb_file_s_expand_path(1, &fname);
I think I solved this problem by declaring fname and path at the top of the
process.c file and then moving those two lines into the Init_process()
function. It worked in testing anyway.
Shall I commit?
Regards,
Dan
_________________________________________________________________
Get some great ideas here for your sweetheart on Valentine''s Day - and
beyond. http://special.msn.com/network/celebrateromance.armx
win32utils-devel@rubyforge.org
2004-Feb-15 19:24 UTC
[Win32utils-devel] Win32::Process fork fragility
Hi,> > Park, > > I was just playing around with the Process.fork/wait that you committed. I > discovered that it''s rather easy to break with this: > > require "win32/process" > include Win32 > > Dir.chdir ".." # This causes the problem > > pid = Win32::Process.fork > > if pid == 0 > puts "In the child" > exit > else > puts "In the parent" > end > > Win32::Process.wait(pid) > > I think the problem lies in this code: > > fname = rb_gv_get("$0"); > ... > path = rb_file_s_expand_path(1, &fname); > > I think I solved this problem by declaring fname and path at the top of the > process.c file and then moving those two lines into the Init_process() > function. It worked in testing anyway. > > Shall I commit? >I guess Win32::Process fork and wait differ from UNIX''s fork and wait in many respects. Thus there are many limits and disadvantages in Win32::Process. But It is usable for certain limited and specific situation. I recommend any code must not exist before Win32::Process.fork except require and variable setting. Anyway please commit your code if it works Regards, Park Heesob --MIME Multi-part separator--