HomePhabricator

init: Try to aquire datadir lock before and after daemonization

Description

init: Try to aquire datadir lock before and after daemonization

Before daemonization, just probe the data directory lock and print an
early error message if possible.

After daemonization get the data directory lock again and hold on to it until exit
This creates a slight window for a race condition to happen, however this condition is harmless: it
will at most make us exit without printing a message to console.

$ src/bitcoind -testnet -daemon
Bitcoin server starting
$ src/bitcoind -testnet -daemon
Error: Cannot obtain a lock on data directory /home/orion/.bitcoin/testnet3. Bitcoin Core is probably already running.

Details

Provenance
Wladimir J. van der Laan <laanwj@gmail.com>Authored on Oct 25 2016, 10:03
deadalnixPushed on May 14 2017, 22:04
Parents
rABC0cc8b6bc44be: init: Split up AppInit2 into multiple phases
Branches
Unknown
Tags
Unknown

Event Timeline

Wladimir J. van der Laan <laanwj@gmail.com> committed rABC16ca0bfd2848: init: Try to aquire datadir lock before and after daemonization (authored by Wladimir J. van der Laan <laanwj@gmail.com>).Nov 29 2016, 11:47