mirror of
https://github.com/tmux/tmux.git
synced 2024-11-16 09:28:51 +00:00
Sync OpenBSD patchset 166:
Pass a set of flags into client_init rather than just a start_server variable. Only one flag now but more to come later.
This commit is contained in:
parent
6708ad19c5
commit
7174c76bf0
8
client.c
8
client.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: client.c,v 1.53 2009-07-01 23:06:32 nicm Exp $ */
|
/* $Id: client.c,v 1.54 2009-07-23 13:15:41 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -36,7 +36,7 @@
|
|||||||
void client_handle_winch(struct client_ctx *);
|
void client_handle_winch(struct client_ctx *);
|
||||||
|
|
||||||
int
|
int
|
||||||
client_init(char *path, struct client_ctx *cctx, int start_server, int flags)
|
client_init(char *path, struct client_ctx *cctx, int cmdflags, int flags)
|
||||||
{
|
{
|
||||||
struct sockaddr_un sa;
|
struct sockaddr_un sa;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
@ -57,7 +57,7 @@ client_init(char *path, struct client_ctx *cctx, int start_server, int flags)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (lstat(path, &sb) != 0) {
|
if (lstat(path, &sb) != 0) {
|
||||||
if (start_server && errno == ENOENT) {
|
if (cmdflags & CMD_STARTSERVER && errno == ENOENT) {
|
||||||
if ((cctx->srv_fd = server_start(path)) == -1)
|
if ((cctx->srv_fd = server_start(path)) == -1)
|
||||||
goto start_failed;
|
goto start_failed;
|
||||||
goto server_started;
|
goto server_started;
|
||||||
@ -83,7 +83,7 @@ client_init(char *path, struct client_ctx *cctx, int start_server, int flags)
|
|||||||
if (connect(
|
if (connect(
|
||||||
cctx->srv_fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1) {
|
cctx->srv_fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1) {
|
||||||
if (errno == ECONNREFUSED) {
|
if (errno == ECONNREFUSED) {
|
||||||
if (unlink(path) != 0 || !start_server)
|
if (unlink(path) != 0 || !(cmdflags & CMD_STARTSERVER))
|
||||||
goto not_found;
|
goto not_found;
|
||||||
if ((cctx->srv_fd = server_start(path)) == -1)
|
if ((cctx->srv_fd = server_start(path)) == -1)
|
||||||
goto start_failed;
|
goto start_failed;
|
||||||
|
11
tmux.c
11
tmux.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tmux.c,v 1.148 2009-07-22 16:53:30 tcunha Exp $ */
|
/* $Id: tmux.c,v 1.149 2009-07-23 13:15:41 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -222,7 +222,7 @@ main(int argc, char **argv)
|
|||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
char *s, *path, *label, *cause, *home, *pass = NULL;
|
char *s, *path, *label, *cause, *home, *pass = NULL;
|
||||||
char cwd[MAXPATHLEN];
|
char cwd[MAXPATHLEN];
|
||||||
int retcode, opt, flags, unlock, start_server;
|
int retcode, opt, flags, unlock, cmdflags = 0;
|
||||||
|
|
||||||
unlock = flags = 0;
|
unlock = flags = 0;
|
||||||
label = path = NULL;
|
label = path = NULL;
|
||||||
@ -399,7 +399,7 @@ main(int argc, char **argv)
|
|||||||
cmdlist = NULL;
|
cmdlist = NULL;
|
||||||
if ((pass = getpass("Password: ")) == NULL)
|
if ((pass = getpass("Password: ")) == NULL)
|
||||||
exit(1);
|
exit(1);
|
||||||
start_server = 0;
|
cmdflags &= ~CMD_STARTSERVER;
|
||||||
} else {
|
} else {
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
cmd = xmalloc(sizeof *cmd);
|
cmd = xmalloc(sizeof *cmd);
|
||||||
@ -416,17 +416,16 @@ main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
start_server = 0;
|
|
||||||
TAILQ_FOREACH(cmd, cmdlist, qentry) {
|
TAILQ_FOREACH(cmd, cmdlist, qentry) {
|
||||||
if (cmd->entry->flags & CMD_STARTSERVER) {
|
if (cmd->entry->flags & CMD_STARTSERVER) {
|
||||||
start_server = 1;
|
cmdflags |= CMD_STARTSERVER;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&cctx, 0, sizeof cctx);
|
memset(&cctx, 0, sizeof cctx);
|
||||||
if (client_init(path, &cctx, start_server, flags) != 0)
|
if (client_init(path, &cctx, cmdflags, flags) != 0)
|
||||||
exit(1);
|
exit(1);
|
||||||
xfree(path);
|
xfree(path);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user