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:
Nicholas Marriott
2012-03-09 09:57:40 +00:00
parent 18012f5b18
commit ac9ebc29a2
3 changed files with 46 additions and 15 deletions

View File

@@ -104,7 +104,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];
@@ -161,6 +161,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) {