Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Process forking problem
- - By Jwosty Date 2011-07-11 23:22
Here's an odd bug I can't seem to fix:

If you try to fork a process with a block, and inside that block somewhere is a call to create a new instance of Gosu::Image. For some reason, it exits the process you just created.
For example, if you try:

Process.fork {
     10.times do |i|
     puts i
     Gosu::Image.new(@window, 'PATH/TO/IMAGE.png', true)
end}


The output should be:

0
1
2
3
4
5
6
7
8
9


But instead (at least for me) it would give me this:

0
Parent - - By jlnr (dev) Date 2011-07-12 09:30 Edited 2011-07-12 11:34
You cannot do this. Processes cannot share anything easily, except for some resources at the operating system level.

What you can *almost* do is to use Thread.new {}, but this is not yet officially supported in Gosu. The code is there but commented out, so the Gosu gem is sadly not thread-safe.
Parent - By Jwosty Date 2011-07-12 14:17
Oh, okay. Thanks!
Up Topic Gosu / Gosu Exchange / Process forking problem

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill