jsl has asked for the wisdom of the Perl Monks concerning the following question:
What I want to do is,--START-- OPEN FILE TO READ AND WRITE; IF ($PID = FORK()) { SLEEP(1); WRITE 'ALPHA'; SLEEP(5); WRITE 'BETA'; } ELSE (DEFINED $PID) { SLEEP(3); READ THE FILE; #Hope to output 'ALPHA' SLEEP(7); READ THE FILE; #Hope to output 'ALPHA' and 'BETA' } CLOSE THE FREAKING FILE; --DONE--
In this program, it opens and closes every time you want to read or write to a file.--START-- IF ($PID = FORK()) { SLEEP(1); open file; WRITE 'ALPHA'; close file; SLEEP(5); open file; WRITE 'BETA'; close file; } ELSE (DEFINED $PID) { SLEEP(3); open file; READ THE FILE; close file; SLEEP(7); open file; READ THE FILE; close file; } --DONE--
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Concurrency : FORK and knife
by enoch (Chaplain) on Jun 15, 2001 at 22:20 UTC | |
|
Re: Concurrency : FORK and knife
by nardo (Friar) on Jun 15, 2001 at 22:30 UTC | |
|
Re: Concurrency : FORK and knife
by mothra (Hermit) on Jun 15, 2001 at 22:22 UTC | |
|
Re: Concurrency : FORK and knife
by jwest (Friar) on Jun 15, 2001 at 22:25 UTC | |
|
Re: Concurrency : FORK and knife
by petral (Curate) on Jun 15, 2001 at 22:23 UTC |