Sync OpenBSD patchset 1043:

Use a lock file and flock() to serialize server start, avoids problems
when running a bunch of tmux from cron at the same time. Based on a diff
from Tim Ruehsen.
This commit is contained in:
Tiago Cunha
2012-03-18 01:28:10 +00:00
parent 9b8fc982ec
commit 40b1d64ce7
3 changed files with 46 additions and 15 deletions

View File

@ -103,7 +103,7 @@ server_create_socket(void)
/* Fork new server. */
int
server_start(void)
server_start(int lockfd, char *lockfile)
{
struct window_pane *wp;
int pair[2];
@ -162,6 +162,10 @@ server_start(void)
server_fd = server_create_socket();
server_client_create(pair[1]);
unlink(lockfile);
xfree(lockfile);
close(lockfd);
if (access(SYSTEM_CFG, R_OK) == 0)
load_cfg(SYSTEM_CFG, NULL, &cfg_causes);
else if (errno != ENOENT) {