in reply to Re^2: Unexpected output from fork (Win32)
in thread Unexpected output from fork (Win32)

A couple of things.

First, as Win32 pseudo-forks are threads, you can (apparently) use threads::shared to share an array (or other data) between them:

From threads::shared POD:

DESCRIPTION

By default, variables are private to each thread, and each newly created thread gets a private copy of each existing variable. This module allows you to share variables across different threads (and pseudoforks on Win32). It is used together with the threads module.

Though I admit I've never actually tried this.

Second. Doing the equivalent of your OP code using threads is much simpler.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
  • Comment on Re^3: Unexpected output from fork (Win32)