Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: forking messages

by dhable (Monk)
on Jan 26, 2002 at 01:07 UTC ( #141646=note: print w/replies, xml ) Need Help??


in reply to forking messages

So you fork 10 times and then all of the processes try to send output to a single source? I don't think you understand the concept of fork very well.

When you fork, you create another process in memory that has an independent set of memory and execution paths. Thus, you really have two programs that can do separate things without marching on top of each other. In your case, you have 10. Since a computer can only run one instruction at a time, the operating system simulates this by switching between the processes for you.

But on most PCs, there is only one STDOUT. So each process is now writing to a single device. The reason your output becomes garbled is because the OS is scheduling the threads in an otder it feels is best, and this isn't what you would expect.

If you need a particular order, don't fork.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2022-05-25 12:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (90 votes). Check out past polls.

    Notices?