Your skill will accomplish what the force of many cannot |
|
PerlMonks |
HPUX corruption of file handle after forkby Abe (Acolyte) |
on Dec 10, 2007 at 14:40 UTC ( [id://656119]=perlquestion: print w/replies, xml ) | Need Help?? |
Abe has asked for the wisdom of the Perl Monks concerning the following question:
Dear Brothers of Logic - I have a big sql file generated by a tool, which I want to scan into separate pieces of sql and execute in parallel. I open the file, loop, and fork upon each complete block, closing the file handle in the child. I find the file handle is corrupted by the fork/child - I think the file position keeps flipping back, because I see the message to STDERR report early blocks repeatedly. Here's the code:
It doesn't matter if I use a name FH for the file handle, or the scalar you see, nor does it if I fail to close $fh in the child. IT WORKS OFF STDIN! I have tried sysopen() too - no good. The likliest thing is I've done something daft and fail to see it, and you monks'll spot it. Otherwise I wonder if it's to do with HPUX specifically, and I've scoured the web for something about this, but see nothing. It works on Windows, but I don't think that's very significant, as that wraps fork() somehow. I can work round this - fine, but I think it's essential to understand it, or we can't use fork(), and that'd be a problem for us (we can't be worrying about only using fork() if we've no files open.) Has anyone seen this, or know of any guidance in the scriptures? Thank you! Abe
Back to
Seekers of Perl Wisdom
|
|