Remove old sockets after error.

This commit is contained in:
Nicholas Marriott 2007-08-28 08:30:36 +00:00
parent 12f7197adb
commit 38b752c1d8
2 changed files with 10 additions and 2 deletions

1
TODO
View File

@ -14,3 +14,4 @@
- mouse handling and some other bits elinks needs
- scrollback
- server doesn't handle SIGTERM anymore...
- sleep(1) to wait for server frankly sucks

11
tmux.c
View File

@ -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)