Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/tmux merge conflicts
details: https://anonhg.NetBSD.org/src/rev/e2c5d2f4d4a9
branches: trunk
changeset: 347523:e2c5d2f4d4a9
user: christos <christos%NetBSD.org@localhost>
date: Wed Aug 31 09:33:20 2016 +0000
description:
merge conflicts
diffstat:
external/bsd/tmux/dist/client.c | 601 ++++++--------
external/bsd/tmux/dist/cmd-attach-session.c | 2 +-
external/bsd/tmux/dist/cmd-capture-pane.c | 24 +-
external/bsd/tmux/dist/cmd-display-message.c | 59 +-
external/bsd/tmux/dist/cmd-if-shell.c | 51 +-
external/bsd/tmux/dist/cmd-load-buffer.c | 54 +-
external/bsd/tmux/dist/cmd-new-session.c | 4 +-
external/bsd/tmux/dist/cmd-new-window.c | 77 +-
external/bsd/tmux/dist/cmd-paste-buffer.c | 24 +-
external/bsd/tmux/dist/cmd-send-keys.c | 69 +-
external/bsd/tmux/dist/cmd-show-messages.c | 56 +-
external/bsd/tmux/dist/cmd-split-window.c | 94 +-
external/bsd/tmux/dist/cmd-string.c | 8 +-
external/bsd/tmux/dist/cmd-wait-for.c | 24 +-
external/bsd/tmux/dist/colour.c | 2 +-
external/bsd/tmux/dist/environ.c | 84 +-
external/bsd/tmux/dist/examples/bash_completion_tmux.sh | 105 --
external/bsd/tmux/dist/examples/h-boetes.conf | 42 -
external/bsd/tmux/dist/examples/n-marriott.conf | 110 --
external/bsd/tmux/dist/examples/screen-keys.conf | 102 --
external/bsd/tmux/dist/examples/t-williams.conf | 104 --
external/bsd/tmux/dist/examples/tmux.vim | 289 -------
external/bsd/tmux/dist/examples/vim-keys.conf | 36 -
external/bsd/tmux/dist/examples/xterm-keys.vim | 49 -
external/bsd/tmux/dist/format.c | 429 +++++++---
external/bsd/tmux/dist/grid-cell.c | 55 -
external/bsd/tmux/dist/grid.c | 193 +++-
external/bsd/tmux/dist/hooks.c | 2 +-
external/bsd/tmux/dist/input-keys.c | 68 +-
external/bsd/tmux/dist/input.c | 128 +-
external/bsd/tmux/dist/job.c | 34 +-
external/bsd/tmux/dist/key-bindings.c | 21 +-
external/bsd/tmux/dist/log.c | 43 +-
external/bsd/tmux/dist/options.c | 78 +-
external/bsd/tmux/dist/paste.c | 11 +-
external/bsd/tmux/dist/proc.c | 2 +-
external/bsd/tmux/dist/screen-write.c | 227 ++--
external/bsd/tmux/dist/screen.c | 8 +-
external/bsd/tmux/dist/server-client.c | 2 +-
external/bsd/tmux/dist/server-fn.c | 144 +--
external/bsd/tmux/dist/session.c | 69 +-
external/bsd/tmux/dist/status.c | 178 ++--
external/bsd/tmux/dist/tmux.1 | 263 ++++--
external/bsd/tmux/dist/tmux.c | 242 ++---
external/bsd/tmux/dist/tmux.h | 630 +++++++++------
external/bsd/tmux/dist/tty-acs.c | 2 +-
external/bsd/tmux/dist/tty-keys.c | 113 +-
external/bsd/tmux/dist/tty-term.c | 23 +-
external/bsd/tmux/dist/utf8.c | 2 +-
external/bsd/tmux/dist/window-copy.c | 298 ++++---
external/bsd/tmux/dist/window.c | 86 +-
external/bsd/tmux/usr.bin/tmux/Makefile | 13 +-
52 files changed, 2473 insertions(+), 2961 deletions(-)
diffs (truncated from 10177 to 300 lines):
diff -r 45d7cf466db2 -r e2c5d2f4d4a9 external/bsd/tmux/dist/client.c
--- a/external/bsd/tmux/dist/client.c Wed Aug 31 09:14:47 2016 +0000
+++ b/external/bsd/tmux/dist/client.c Wed Aug 31 09:33:20 2016 +0000
@@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
- * Copyright (c) 2007 Nicholas Marriott <nicm%users.sourceforge.net@localhost>
+ * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott%gmail.com@localhost>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -33,10 +33,10 @@
#include "tmux.h"
-int client_flags;
-struct imsgbuf client_ibuf;
-struct event client_event;
-struct event client_stdin;
+struct tmuxproc *client_proc;
+struct tmuxpeer *client_peer;
+int client_flags;
+struct event client_stdin;
enum {
CLIENT_EXIT_NONE,
CLIENT_EXIT_DETACHED,
@@ -47,41 +47,40 @@
CLIENT_EXIT_EXITED,
CLIENT_EXIT_SERVER_EXITED,
} client_exitreason = CLIENT_EXIT_NONE;
-int client_exitval;
-enum msgtype client_exittype;
-const char *client_exitsession;
-int client_attached;
+int client_exitval;
+enum msgtype client_exittype;
+const char *client_exitsession;
+int client_attached;
-__dead void client_exec(const char *);
+__dead void client_exec(const char *,const char *);
int client_get_lock(char *);
-int client_connect(struct event_base *, char *, int);
-void client_send_identify(const char *, int);
-int client_write_one(enum msgtype, int, const void *, size_t);
-int client_write_server(enum msgtype, const void *, size_t);
-void client_update_event(void);
-void client_signal(int, short, void *);
+int client_connect(struct event_base *, const char *, int);
+void client_send_identify(const char *, const char *);
void client_stdin_callback(int, short, void *);
void client_write(int, const char *, size_t);
-void client_callback(int, short, void *);
-int client_dispatch_attached(void);
-int client_dispatch_wait(void);
+void client_signal(int);
+void client_dispatch(struct imsg *, void *);
+void client_dispatch_attached(struct imsg *);
+void client_dispatch_wait(struct imsg *, const char *);
const char *client_exit_message(void);
/*
* Get server create lock. If already held then server start is happening in
- * another client, so block until the lock is released and return -1 to
- * retry. Ignore other errors - just continue and start the server without the
- * lock.
+ * another client, so block until the lock is released and return -2 to
+ * retry. Return -1 on failure to continue and start the server anyway.
*/
int
client_get_lock(char *lockfile)
{
int lockfd;
- if ((lockfd = open(lockfile, O_WRONLY|O_CREAT, 0600)) == -1)
- fatal("open failed");
log_debug("lock file is %s", lockfile);
+ if ((lockfd = open(lockfile, O_WRONLY|O_CREAT, 0600)) == -1) {
+ log_debug("open failed: %s", strerror(errno));
+ return (-1);
+ }
+
if (flock(lockfd, LOCK_EX|LOCK_NB) == -1) {
log_debug("flock failed: %s", strerror(errno));
if (errno != EAGAIN)
@@ -89,7 +88,7 @@
while (flock(lockfd, LOCK_EX) == -1 && errno == EINTR)
/* nothing */;
close(lockfd);
- return (-1);
+ return (-2);
}
log_debug("flock succeeded");
@@ -98,7 +97,7 @@
/* Connect client to server. */
int
-client_connect(struct event_base *base, char *path, int start_server)
+client_connect(struct event_base *base, const char *path, int start_server)
{
struct sockaddr_un sa;
size_t size;
@@ -116,10 +115,10 @@
retry:
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
- fatal("socket failed");
+ return (-1);
log_debug("trying connect");
- if (connect(fd, (struct sockaddr *) &sa, sizeof(sa)) == -1) {
+ if (connect(fd, (struct sockaddr *)&sa, sizeof sa) == -1) {
log_debug("connect failed: %s", strerror(errno));
if (errno != ECONNREFUSED && errno != ENOENT)
goto failed;
@@ -129,12 +128,16 @@
if (!locked) {
xasprintf(&lockfile, "%s.lock", path);
- if ((lockfd = client_get_lock(lockfile)) == -1) {
- log_debug("didn't get lock");
+ if ((lockfd = client_get_lock(lockfile)) < 0) {
+ log_debug("didn't get lock (%d)", lockfd);
+
free(lockfile);
- goto retry;
+ lockfile = NULL;
+
+ if (lockfd == -2)
+ goto retry;
}
- log_debug("got lock");
+ log_debug("got lock (%d)", lockfd);
/*
* Always retry at least once, even if we got the lock,
@@ -146,7 +149,7 @@
goto retry;
}
- if (unlink(path) != 0 && errno != ENOENT) {
+ if (lockfd >= 0 && unlink(path) != 0 && errno != ENOENT) {
free(lockfile);
close(lockfd);
return (-1);
@@ -154,7 +157,7 @@
fd = server_start(base, lockfd, lockfile);
}
- if (locked) {
+ if (locked && lockfd >= 0) {
free(lockfile);
close(lockfd);
}
@@ -209,25 +212,29 @@
/* Client main loop. */
int
-client_main(struct event_base *base, int argc, char **argv, int flags)
+client_main(struct event_base *base, int argc, char **argv, int flags,
+ const char *shellcmd)
{
struct cmd *cmd;
struct cmd_list *cmdlist;
struct msg_command_data *data;
- int cmdflags, fd, i, cwd;
- const char* ttynam;
+ int cmdflags, fd, i;
+ const char *ttynam, *cwd;
pid_t ppid;
enum msgtype msg;
- char *cause;
+ char *cause, path[PATH_MAX];
struct termios tio, saved_tio;
size_t size;
+ /* Ignore SIGCHLD now or daemon() in the server will leave a zombie. */
+ signal(SIGCHLD, SIG_IGN);
+
/* Save the flags. */
client_flags = flags;
/* Set up the initial command. */
cmdflags = 0;
- if (shell_cmd != NULL) {
+ if (shellcmd != NULL) {
msg = MSG_SHELL;
cmdflags = CMD_STARTSERVER;
} else if (argc == 0) {
@@ -254,8 +261,8 @@
cmd_list_free(cmdlist);
}
- /* Establish signal handlers. */
- set_signals(client_signal);
+ /* Create client process structure (starts logging). */
+ client_proc = proc_start("client", base, 0, client_signal);
/* Initialize the client socket and start the server. */
fd = client_connect(base, socket_path, cmdflags & CMD_STARTSERVER);
@@ -269,10 +276,14 @@
}
return (1);
}
+ client_peer = proc_add_peer(client_proc, fd, client_dispatch,
+ __UNCONST(shellcmd));
/* Save these before pledge(). */
- if ((cwd = open(".", O_RDONLY)) == -1)
- cwd = open("/", O_RDONLY);
+ if ((cwd = getcwd(path, sizeof path)) == NULL) {
+ if ((cwd = find_home()) == NULL)
+ cwd = "/";
+ }
if ((ttynam = ttyname(STDIN_FILENO)) == NULL)
ttynam = "";
@@ -291,31 +302,18 @@
#endif
/* Free stuff that is not used in the client. */
- options_free(&global_options);
- options_free(&global_s_options);
- options_free(&global_w_options);
- environ_free(&global_environ);
-
- /* Set process title, log and signals now this is the client. */
-#ifdef HAVE_SETPROCTITLE
- setproctitle("client (%s)", socket_path);
-#endif
- logfile("client");
-
- /* Create imsg. */
- imsg_init(&client_ibuf, fd);
- event_set(&client_event, fd, EV_READ, client_callback, NULL);
+ options_free(global_options);
+ options_free(global_s_options);
+ options_free(global_w_options);
+ environ_free(global_environ);
/* Create stdin handler. */
setblocking(STDIN_FILENO, 0);
event_set(&client_stdin, STDIN_FILENO, EV_READ|EV_PERSIST,
client_stdin_callback, NULL);
if (client_flags & CLIENT_CONTROLCONTROL) {
- if (tcgetattr(STDIN_FILENO, &saved_tio) != 0) {
- fprintf(stderr, "tcgetattr failed: %s\n",
- strerror(errno));
- return (1);
- }
+ if (tcgetattr(STDIN_FILENO, &saved_tio) != 0)
+ fatal("tcgetattr failed");
cfmakeraw(&tio);
tio.c_iflag = ICRNL|IXANY;
tio.c_oflag = OPOST|ONLCR;
@@ -331,7 +329,7 @@
}
/* Send identify messages. */
- client_send_identify(ttynam, cwd); /* closes cwd */
+ client_send_identify(ttynam, cwd);
/* Send first command. */
if (msg == MSG_COMMAND) {
@@ -351,18 +349,17 @@
size += sizeof *data;
/* Send the command. */
- if (client_write_server(msg, data, size) != 0) {
+ if (proc_send(client_peer, msg, -1, data, size) != 0) {
fprintf(stderr, "failed to send command\n");
free(data);
return (1);
}
free(data);
} else if (msg == MSG_SHELL)
- client_write_server(msg, NULL, 0);
+ proc_send(client_peer, msg, -1, NULL, 0);
- /* Set the event and dispatch. */
- client_update_event();
- event_dispatch();
+ /* Start main loop. */
+ proc_loop(client_proc, NULL);
/* Print the exit message, if any, and exit. */
if (client_attached) {
@@ -379,14 +376,15 @@
printf("%%exit\n");
printf("\033\\");
tcsetattr(STDOUT_FILENO, TCSAFLUSH, &saved_tio);
- }
+ } else if (client_exitreason != CLIENT_EXIT_NONE)
+ fprintf(stderr, "%s\n", client_exit_message());
setblocking(STDIN_FILENO, 1);
return (client_exitval);
}
Home |
Main Index |
Thread Index |
Old Index