Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Concurrency : FORK and knife

by nardo (Friar)
on Jun 15, 2001 at 22:30 UTC ( [id://88886]=note: print w/replies, xml ) Need Help??


in reply to Concurrency : FORK and knife

The data from your writes isn't being flushed to disk.
use FileHandle; use strict; my $data; my $pid; open(FILE, '+>outfile'); FILE->autoflush(1); if(($pid = fork())) { sleep(1); print FILE 'ALPHA'; sleep(5); print FILE 'BETA'; wait(); } else { sleep(3); seek(FILE, 0, 0); read(FILE, $data, (stat(FILE))[7]); print $data, "\n"; sleep(7); seek(FILE, 0, 0); read(FILE, $data, (stat(FILE))[7]); print $data, "\n"; } close(FILE);


will output:

ALPHA
ALPHABETA

which I think is what you want.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://88886]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-25 22:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found