At Tue, 02 Apr 2013 12:13:23 +0900, MORITA Kazutaka wrote: > > At Tue, 2 Apr 2013 11:40:48 +0900, > Hitoshi Mitake wrote: > > > > sheep employes lockf() for mutex of lock_base_dir() now. But the > > lockf() is not suitable for sheep bacause sheep calls daemon(3) after > > the lockf(). daemon(3) forks internally and a parent process exits > > immediately. In a case of sheep, daemon() must be called after locking > > base dir so the lock owner, parent process, exits and the lock will be > > released even though the child process is running. This is the reason > > current lock_base_dir() doesn't work well. > > > > This patch makes lock_base_dir() correct with a new mechanism based on > > O_EXCL of open(2). > > The lock will not be released if the program exits unexpectedly, no?
Sorry, unlock_base_dir() should also be called in crash_handler(). I'll fix it in v2. > > init_base_path() was called after daemon() in the old code, and the > order was changed in f092748b. I think we should fix the commit. I think calling daemon() before init_base_path() is not a good idea. Because after calling daemon(), error messages can be written to sheep.log only. And this means that multiple sheeps share single sheep.log file. Thanks, Hitoshi -- sheepdog mailing list sheepdog@lists.wpkg.org http://lists.wpkg.org/mailman/listinfo/sheepdog