syphilis has asked for the wisdom of the Perl Monks concerning the following question:
On linux that script fulfils my expectations and outputs:use warnings; #use Inline C => Config => # BUILD_NOISY => 1; use Inline C => <<'EOC'; static int x = 5; void set_x(int z) { x = z; } void get_x(char * id) { printf("%s %d\n", id, x); } EOC get_x('1st call:'); if($pid = fork()) { waitpid($pid,0); } else { set_x(10); get_x('2nd call:'); exit(0); } get_x('3rd call:');
But on Win32, I get:1st call: 5 2nd call: 10 3rd call: 5
The basic requirement is that the script forks; the child then alters the value of an XS global and exits; that global then still retains its original value.1st call: 5 2nd call: 10 3rd call: 10
It yields (as expected and desired):use warnings; $g = 5; print "1st call: $g\n"; if($pid = fork()) { waitpid($pid,0); } else { $g = 10; print "2nd call: $g\n"; exit(0); } print "3rd call: $g\n";
Cheers,1st call: 5 2nd call: 10 3rd call: 5
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Win32, fork and XS globals (cygwin)
by tye (Sage) on Oct 02, 2011 at 05:00 UTC | |
|
Re: Win32, fork and XS globals
by BrowserUk (Patriarch) on Oct 02, 2011 at 05:15 UTC | |
by ikegami (Patriarch) on Oct 02, 2011 at 05:38 UTC | |
by syphilis (Archbishop) on Oct 02, 2011 at 08:15 UTC | |
by BrowserUk (Patriarch) on Oct 02, 2011 at 06:09 UTC | |
by ikegami (Patriarch) on Oct 02, 2011 at 09:33 UTC | |
by BrowserUk (Patriarch) on Oct 02, 2011 at 10:16 UTC | |
| |
by syphilis (Archbishop) on Oct 11, 2011 at 13:48 UTC | |
by Corion (Patriarch) on Oct 11, 2011 at 13:52 UTC | |
by BrowserUk (Patriarch) on Oct 11, 2011 at 17:17 UTC | |
by syphilis (Archbishop) on Oct 12, 2011 at 11:43 UTC | |
by BrowserUk (Patriarch) on Oct 13, 2011 at 01:17 UTC |