in reply to DB_Filelock issues

File locking across fork() calls depends greatly upon your operating system's support of flock() (and, I suppose, fork()). You'll probably need to follow up with a bit more information about your environment and some code. (The alternative is that someone will make a wild guess that turns out to be right. If it were up to me, I'd say "don't flock before you fork".)

Replies are listed 'Best First'.
Re: DB_Filelock issues
by Abigail-II (Bishop) on Jun 07, 2002 at 11:15 UTC
    Stevens explicitely states that file locks by the parent are not inherited by the child, without stating any differences between BSD and SysV.

    You said, "don't flock() before you fork", but there's a (neat?) hack involving flocking before a fork to make sure a parent does something before a child can:

    1. flock a file exclusively.
    2. fork.
    3. let the child flock the file.
    4. now the parent can do her stuff.
    5. parent releases the flock.
    6. child releases the flock.
    7. both child and parent go their merry ways.
    I was *this* close to actually use that trick (in a C program) earlier this week.

    Abigail