summaryrefslogtreecommitdiffstats
path: root/server.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2012-03-09 09:57:40 +0000
committerNicholas Marriott <nicm@openbsd.org>2012-03-09 09:57:40 +0000
commitac9ebc29a26c1e7c19e1c9a58fef42bfc75d2100 (patch)
tree67db23a9c851a73c28eca3fc8bd194aa1b8b59c4 /server.c
parent18012f5b18e0ff8bdb95d70dd0fbc9c03a05f2f5 (diff)
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.
Diffstat (limited to 'server.c')
-rw-r--r--server.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/server.c b/server.c
index a548a694..c269535d 100644
--- a/server.c
+++ b/server.c
@@ -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) {