aboutsummaryrefslogtreecommitdiff
path: root/tmux.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2007-08-28 08:30:36 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2007-08-28 08:30:36 +0000
commit38b752c1d8338b78c86eb863c028cc058708828f (patch)
treebcbfb09f744f605d489eb9caa916bca6773daa62 /tmux.c
parent12f7197adbf37a430266ecbe355ebb568b69eeb6 (diff)
downloadrtmux-38b752c1d8338b78c86eb863c028cc058708828f.tar.gz
rtmux-38b752c1d8338b78c86eb863c028cc058708828f.tar.bz2
rtmux-38b752c1d8338b78c86eb863c028cc058708828f.zip
Remove old sockets after error.
Diffstat (limited to 'tmux.c')
-rw-r--r--tmux.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/tmux.c b/tmux.c
index ead0062d..b3ef4fa3 100644
--- a/tmux.c
+++ b/tmux.c
@@ -1,4 +1,4 @@
-/* $Id: tmux.c,v 1.4 2007-08-27 13:53:55 nicm Exp $ */
+/* $Id: tmux.c,v 1.5 2007-08-28 08:30:36 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -155,6 +155,8 @@ main(int argc, char **argv)
xfree(path);
/* Start server if necessary. */
+ n = 0;
+restart:
if (stat(socket_path, &sb) != 0) {
if (errno != ENOENT)
err(1, "%s", socket_path);
@@ -169,8 +171,13 @@ main(int argc, char **argv)
}
/* Connect to server. */
- if ((server_fd = connect_server()) == -1)
+ if ((server_fd = connect_server()) == -1) {
+ if (errno == ECONNREFUSED && n++ < 5) {
+ unlink(socket_path);
+ goto restart;
+ }
errx(1, "couldn't find server");
+ }
if ((mode = fcntl(server_fd, F_GETFL)) == -1)
err(1, "fcntl");
if (fcntl(server_fd, F_SETFL, mode|O_NONBLOCK) == -1)