Besides the comments about the inverted test on the return from fork(),
another issue to bring up is that the LOCK_UN is usually unnecessary,
and can even be detrimental. A close() doesn't an implicit flush and
unlock. Traditionally, if you unlocked before closing, you did the last
write without owning the lock. The developers of perl saw this problem
occur frequently, and had flock perform an implicit flush before
unlocking. If you are writing code that needs to be robust enough that
you are checking the return value from close(), you might not want to
depend on the implicit flush because you have no way of checking if the
flush succeeds or fails.
In most cases, you can just leave off the LOCK_UN, and just close the
file.
On another point. The commands strace on Linux and truss on Solaris are
useful ways of checking the interactions between a program and the
kernel. It probably would have helped you out in this case.
On Monday, June 21, 2004, at 10:10 PM, Ian Langworth wrote:
On Mon, 21 Jun 2004 18:49:22 -0400, Andrew Langmead
<[EMAIL PROTECTED]> wrote:
(something I sent via private email and not to the list.)
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm