If you have to sort the results anyway, just dodge the bullet and have each of your processes write to separate files. Then sort the files into one. You can't sort until you get the last line anyway, so there is no loss of parallelism.
Also, a threaded solution is possible if you are interested.
In reply to Re^3: What the flock!? Concurrency issues in file writing.
by BrowserUk
in thread What the flock!? Concurrency issues in file writing.
by suaveant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |