Re: On file locking - Mailing list pgsql-hackers

From Antti Haapala
Subject Re: On file locking
Date
Msg-id Pine.GSO.4.44.0301311425400.26712-100000@paju.oulu.fi
Whole thread Raw
In response to Re: On file locking  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: On file locking  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
> But this only wins if a child process inheriting an open file also
> inherits copies of any locks held by the parent.  If not, then the
> issue is moot.  Anybody have any idea if file locks work that way?
> Is it portable??

From RedHat 8.0 manages fork(2):

SYNOPSIS      #include <sys/types.h>      #include <unistd.h>
      pid_t fork(void);

DESCRIPTION      fork  creates a child process that differs from the parent process only      in its PID and PPID, and
inthe fact that resource utilizations are set      to 0.  File locks and pending signals are not inherited.
^^^^^^^^^^                    ^^^^^^^^^^^^^^^^^^
 

And from SunOS 5.8 flock    Locks are on files, not file  descriptors.   That  is,  file    descriptors  duplicated
through dup(2)  or  fork(2) do not    result in multiple instances of a lock, but rather  multiple    references to a
singlelock.  If a process holding a lock on    a file forks and the child explicitly unlocks the file,  the    parent
will lose  its  lock.  Locks are not inherited by a    child process.
 

If I understand correctly it says that if parent dies, file is unlocked no
matter if there's children still running?

-- 
Antti Haapala



pgsql-hackers by date:

Previous
From: "D'Arcy J.M. Cain"
Date:
Subject: Re: PostgreSQL, NetBSD and NFS
Next
From: Greg Copeland
Date:
Subject: Odd website behavior...