Berkeley CSUA MOTD:Entry 10231
Berkeley CSUA MOTD
 
WIKI | FAQ | Tech FAQ
http://csua.com/feed/
2025/05/24 [General] UID:1000 Activity:popular
5/24    

2003/9/17-18 [Computer/SW/Languages/Perl] UID:10231 Activity:nil
9/16    I have a perl script that forks off children who do some
        IO-bound work and then print a result to stdout.  Each child
        locks the STDOUT filehandle like this
                flock(STDOUT, LOCK_EX);
                 &dump_results();
                flock(STDOUT, LOCK_UN);
        but I still get child A's output mixed in with child B's.  What am
        I doing wrong?
        \_ I recall something in the perl book (I have 1st ed) about switching
           between filehandles for output.  They give some example code.  Sorry
           I can't be more helpful.
           \_ thanks, I put in some "|| die" messages and I got
              "Operation not permitted."  I switched to using an actual
              file and that seems to work.