Check if /tmp/urbit.sock already exists

This commit is contained in:
Raymond Pasco 2017-03-14 23:06:13 -04:00
parent f3f86941b3
commit 1d052ab7ba

View File

@ -1,3 +1,4 @@
#include <unistd.h>
#include <uv.h>
#include "all.h"
#include "vere/vere.h"
@ -416,6 +417,10 @@ u3_king_commence()
}
/* listen on command socket */
if ( access("/tmp/urbit.sock", F_OK) != -1 ) {
fprintf(stderr, "/tmp/urbit.sock exists - is urbit already running?\r\n");
exit(1);
}
uv_pipe_init(u3L, &u3K.cmd_u, 0);
uv_pipe_bind(&u3K.cmd_u, "/tmp/urbit.sock");
uv_listen((uv_stream_t *)&u3K.cmd_u, 128, _king_socket_connect);