lockfiles & fork()

2 messages, 2 authors, 2016-08-11 · open the first message on its own page

lockfiles & fork()

From: Johannes Schindelin <hidden>
Date: 2016-08-11 19:20:12

Hi,

when you setup a lockfile, and then fork(), you could easily end up with 
atexit() kicking in to remove the lockfile, before the main process has a 
chance to commit. (Yes, I need to hold the lock long before the fork()).

Any ideas how to solve the problem?

Ciao,
Dscho

Re: lockfiles & fork()

From: Linus Torvalds <torvalds@osdl.org>
Date: 2016-08-11 20:39:14


On Sat, 28 Oct 2006, Johannes Schindelin wrote:
when you setup a lockfile, and then fork(), you could easily end up with 
atexit() kicking in to remove the lockfile, before the main process has a 
chance to commit. (Yes, I need to hold the lock long before the fork()).
The easiest way to handle this would be for the lockfile logic to just 
save the pid associated with each lockfile... And for the atexit function 
to just ignore it if the pid doesn't match. 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help