[Win32utils-devel] Win32::Process fork fragility

win32utils-devel at rubyforge.org win32utils-devel at rubyforge.org
Mon Feb 16 09:19:09 EST 2004


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--



More information about the win32utils-devel mailing list