I did not know that pids in Windows were negative.
They're not. That's why negative numbers were used to id the pseudo-processes created by fork.
Do you know what causes this incompatibility?
The usual possibilities:
- A race condition. Not very likely here considering the simplicity of the code and the repeatability of the problem.
- Something that should only be called once is being called once for each thread.
- Something is called from one thread but expects to be called from another.
On the Perl side, every variable gets copied when you create a new thread. That makes Perl code more-or-less thread-safe by default. But that's not the case on the C component of XS modules. C variables are shared among threads "by default".
Workarounds:
- If you only need Win32::OLE in the parent, you could try loading it after all threads have been created. This will probably entail using require instead of use.
- If you only need Win32::OLE in the child, you could try loading it from the thread. This will probably entail using require instead of use.
- If you need Win32::OLE in both the parent and the child, it probably won't work based on the evidence we've seen. Using separate processes would do the trick.
| [reply] [d/l] [select] |
Your suggestion to require the module instead of 'using' it did the work. Thanks a lot for all the useful info and help!
Athanasia
| [reply] |