mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Adjust $TMUX environ var to include session index, and don't compact session list on release. Also fix some argument types.
This commit is contained in:
		
							
								
								
									
										14
									
								
								TODO
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								TODO
									
									
									
									
									
								
							@@ -13,10 +13,10 @@
 | 
				
			|||||||
- scrollback
 | 
					- scrollback
 | 
				
			||||||
- server doesn't handle SIGTERM anymore...
 | 
					- server doesn't handle SIGTERM anymore...
 | 
				
			||||||
- sleep(1) to wait for server frankly sucks
 | 
					- sleep(1) to wait for server frankly sucks
 | 
				
			||||||
- two-way communication (rename) sucks. lose it and use a command line option
 | 
					 | 
				
			||||||
  for everythin
 | 
					 | 
				
			||||||
- toolbar, copy/paste
 | 
					- toolbar, copy/paste
 | 
				
			||||||
- cleanup/redesign IPC
 | 
					- cleanup/redesign IPC
 | 
				
			||||||
 | 
					- the whole input/screen/local thing sucks a bit, reorganise/redesign it
 | 
				
			||||||
 | 
					- line mode/char-at-a-time mode a la telnet?
 | 
				
			||||||
- some of the uses of buffers really sucks. buffer_reverse_add/remove,
 | 
					- some of the uses of buffers really sucks. buffer_reverse_add/remove,
 | 
				
			||||||
  and buffer_insert_range/delete_range are abominations. this should be
 | 
					  and buffer_insert_range/delete_range are abominations. this should be
 | 
				
			||||||
  rethought
 | 
					  rethought
 | 
				
			||||||
@@ -32,3 +32,13 @@
 | 
				
			|||||||
	- inside tmux, check $TMUX (pid:session or something)
 | 
						- inside tmux, check $TMUX (pid:session or something)
 | 
				
			||||||
        - otherwise if 1 session, use it
 | 
					        - otherwise if 1 session, use it
 | 
				
			||||||
	- otherwise bail with error
 | 
						- otherwise bail with error
 | 
				
			||||||
 | 
					- keys to add:
 | 
				
			||||||
 | 
						i : show window info (show name, title, size, tty, ...)
 | 
				
			||||||
 | 
					- commands to add:
 | 
				
			||||||
 | 
						rename window/sessions
 | 
				
			||||||
 | 
						swap windows
 | 
				
			||||||
 | 
						link/copy windows
 | 
				
			||||||
 | 
						detach session
 | 
				
			||||||
 | 
						unlink window (... what about windows not linked to any session???)
 | 
				
			||||||
 | 
						close window
 | 
				
			||||||
 | 
						kill session
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: client-cmd.c,v 1.3 2007-09-26 18:50:49 nicm Exp $ */
 | 
					/* $Id: client-cmd.c,v 1.4 2007-09-27 09:15:58 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -58,7 +58,7 @@ struct cmd client_cmd_table[] = {
 | 
				
			|||||||
	{ 'L', client_cmd_fn_msg, MSG_LAST },
 | 
						{ 'L', client_cmd_fn_msg, MSG_LAST },
 | 
				
			||||||
	{ 'l', client_cmd_fn_msg, MSG_LAST },
 | 
						{ 'l', client_cmd_fn_msg, MSG_LAST },
 | 
				
			||||||
	{ 'W', client_cmd_fn_msg, MSG_WINDOWLIST },
 | 
						{ 'W', client_cmd_fn_msg, MSG_WINDOWLIST },
 | 
				
			||||||
	{ 'w', client_cmd_fn_msg, MSG_WINDOWLIST }
 | 
						{ 'w', client_cmd_fn_msg, MSG_WINDOWLIST },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
#define NCLIENTCMD (sizeof client_cmd_table / sizeof client_cmd_table[0])
 | 
					#define NCLIENTCMD (sizeof client_cmd_table / sizeof client_cmd_table[0])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										21
									
								
								server-fn.c
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								server-fn.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: server-fn.c,v 1.2 2007-09-26 18:09:23 nicm Exp $ */
 | 
					/* $Id: server-fn.c,v 1.3 2007-09-27 09:15:58 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -24,11 +24,13 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* Write command to a client. */
 | 
					/* Write command to a client. */
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
server_write_client(struct client *c, u_int cmd, void *buf, size_t len)
 | 
					server_write_client(struct client *c, enum hdrtype type, void *buf, size_t len)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct hdr	 hdr;
 | 
						struct hdr	 hdr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	hdr.type = cmd;
 | 
						log_debug("writing %d to client %d", type, c->fd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						hdr.type = type;
 | 
				
			||||||
	hdr.size = len;
 | 
						hdr.size = len;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	buffer_write(c->out, &hdr, sizeof hdr);
 | 
						buffer_write(c->out, &hdr, sizeof hdr);
 | 
				
			||||||
@@ -39,11 +41,13 @@ server_write_client(struct client *c, u_int cmd, void *buf, size_t len)
 | 
				
			|||||||
/* Write command to a client with two buffers. */
 | 
					/* Write command to a client with two buffers. */
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
server_write_client2(struct client *c,
 | 
					server_write_client2(struct client *c,
 | 
				
			||||||
    u_int cmd, void *buf1, size_t len1, void *buf2, size_t len2)
 | 
					    enum hdrtype type, void *buf1, size_t len1, void *buf2, size_t len2)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct hdr	 hdr;
 | 
						struct hdr	 hdr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	hdr.type = cmd;
 | 
						log_debug("writing %d to client %d", type, c->fd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						hdr.type = type;
 | 
				
			||||||
	hdr.size = len1 + len2;
 | 
						hdr.size = len1 + len2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	buffer_write(c->out, &hdr, sizeof hdr);
 | 
						buffer_write(c->out, &hdr, sizeof hdr);
 | 
				
			||||||
@@ -55,19 +59,22 @@ server_write_client2(struct client *c,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* Write command to all clients attached to a specific window. */
 | 
					/* Write command to all clients attached to a specific window. */
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
server_write_clients(struct window *w, u_int cmd, void *buf, size_t len)
 | 
					server_write_clients(
 | 
				
			||||||
 | 
					    struct window *w, enum hdrtype type, void *buf, size_t len)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct client	*c;
 | 
						struct client	*c;
 | 
				
			||||||
 	struct hdr	 hdr;
 | 
					 	struct hdr	 hdr;
 | 
				
			||||||
	u_int		 i;
 | 
						u_int		 i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	hdr.type = cmd;
 | 
						hdr.type = type;
 | 
				
			||||||
	hdr.size = len;
 | 
						hdr.size = len;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
 | 
						for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
 | 
				
			||||||
		c = ARRAY_ITEM(&clients, i);
 | 
							c = ARRAY_ITEM(&clients, i);
 | 
				
			||||||
		if (c != NULL && c->session != NULL) {
 | 
							if (c != NULL && c->session != NULL) {
 | 
				
			||||||
			if (c->session->window == w) {
 | 
								if (c->session->window == w) {
 | 
				
			||||||
 | 
									log_debug(
 | 
				
			||||||
 | 
									    "writing %d to clients: %d", type, c->fd);
 | 
				
			||||||
				buffer_write(c->out, &hdr, sizeof hdr);
 | 
									buffer_write(c->out, &hdr, sizeof hdr);
 | 
				
			||||||
				if (buf != NULL)
 | 
									if (buf != NULL)
 | 
				
			||||||
					buffer_write(c->out, buf, len);
 | 
										buffer_write(c->out, buf, len);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								server.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								server.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: server.c,v 1.14 2007-09-26 18:09:23 nicm Exp $ */
 | 
					/* $Id: server.c,v 1.15 2007-09-27 09:15:58 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -321,6 +321,8 @@ server_lost_window(struct window *w)
 | 
				
			|||||||
	u_int		 i, j;
 | 
						u_int		 i, j;
 | 
				
			||||||
	int		 destroyed;
 | 
						int		 destroyed;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						log_debug("lost window %d", w->fd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
 | 
						for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
 | 
				
			||||||
		s = ARRAY_ITEM(&sessions, i);
 | 
							s = ARRAY_ITEM(&sessions, i);
 | 
				
			||||||
		if (s == NULL)
 | 
							if (s == NULL)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										29
									
								
								session.c
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								session.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: session.c,v 1.15 2007-09-21 20:45:05 nicm Exp $ */
 | 
					/* $Id: session.c,v 1.16 2007-09-27 09:15:58 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -20,6 +20,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "tmux.h"
 | 
					#include "tmux.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -54,11 +55,6 @@ session_create(const char *name, const char *cmd, u_int sx, u_int sy)
 | 
				
			|||||||
	s->window = s->last = NULL;
 | 
						s->window = s->last = NULL;
 | 
				
			||||||
	ARRAY_INIT(&s->windows);
 | 
						ARRAY_INIT(&s->windows);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (session_new(s, cmd, sx, sy) != 0) {
 | 
					 | 
				
			||||||
		xfree(s);
 | 
					 | 
				
			||||||
		return (NULL);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
 | 
						for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
 | 
				
			||||||
		if (ARRAY_ITEM(&sessions, i) == NULL) {
 | 
							if (ARRAY_ITEM(&sessions, i) == NULL) {
 | 
				
			||||||
			ARRAY_SET(&sessions, i, s);
 | 
								ARRAY_SET(&sessions, i, s);
 | 
				
			||||||
@@ -73,6 +69,11 @@ session_create(const char *name, const char *cmd, u_int sx, u_int sy)
 | 
				
			|||||||
	else
 | 
						else
 | 
				
			||||||
		xsnprintf(s->name, sizeof s->name, "%u", i);
 | 
							xsnprintf(s->name, sizeof s->name, "%u", i);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (session_new(s, cmd, sx, sy) != 0) {
 | 
				
			||||||
 | 
							session_destroy(s);
 | 
				
			||||||
 | 
							return (NULL);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return (s);
 | 
						return (s);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -84,8 +85,10 @@ session_destroy(struct session *s)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	if (session_index(s, &i) != 0)
 | 
						if (session_index(s, &i) != 0)
 | 
				
			||||||
		fatalx("session not found");
 | 
							fatalx("session not found");
 | 
				
			||||||
	ARRAY_REMOVE(&sessions, i);
 | 
						ARRAY_SET(&sessions, i, NULL);
 | 
				
			||||||
 | 
						while (!ARRAY_EMPTY(&sessions) && ARRAY_LAST(&sessions) == NULL)
 | 
				
			||||||
 | 
							ARRAY_TRUNC(&sessions, 1);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
	while (!ARRAY_EMPTY(&s->windows))
 | 
						while (!ARRAY_EMPTY(&s->windows))
 | 
				
			||||||
		window_remove(&s->windows, ARRAY_FIRST(&s->windows));
 | 
							window_remove(&s->windows, ARRAY_FIRST(&s->windows));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -108,8 +111,16 @@ int
 | 
				
			|||||||
session_new(struct session *s, const char *cmd, u_int sx, u_int sy)
 | 
					session_new(struct session *s, const char *cmd, u_int sx, u_int sy)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct window	*w;
 | 
						struct window	*w;
 | 
				
			||||||
 | 
						const char	*environ[] = { NULL, "TERM=screen", NULL };
 | 
				
			||||||
 | 
						char		 blk[256];
 | 
				
			||||||
 | 
						u_int		 i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((w = window_create(cmd, sx, sy)) == NULL)
 | 
						if (session_index(s, &i) != 0)
 | 
				
			||||||
 | 
							fatalx("session not found");
 | 
				
			||||||
 | 
						xsnprintf(blk, sizeof blk, "TMUX=%ld,%u", (long) getpid(), i);
 | 
				
			||||||
 | 
						environ[0] = blk;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						if ((w = window_create(cmd, environ, sx, sy)) == NULL)
 | 
				
			||||||
		return (-1);
 | 
							return (-1);
 | 
				
			||||||
	session_attach(s, w);
 | 
						session_attach(s, w);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										8
									
								
								tmux.c
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								tmux.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: tmux.c,v 1.13 2007-09-26 19:38:42 nicm Exp $ */
 | 
					/* $Id: tmux.c,v 1.14 2007-09-27 09:15:58 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -45,8 +45,10 @@ struct op {
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
struct op op_table[] = {
 | 
					struct op op_table[] = {
 | 
				
			||||||
	{ "attach", NULL, op_attach },
 | 
						{ "attach", NULL, op_attach },
 | 
				
			||||||
	{ "list-sessions", "ls", op_list },
 | 
						{ "list-sessions", "ls", op_list/*_sessions*/ },
 | 
				
			||||||
	{ "new-session", "new", op_new },
 | 
						{ "new-session", "new", op_new/*_session*/ },
 | 
				
			||||||
 | 
					//	{ "rename-window", "rw", op_rename_window },
 | 
				
			||||||
 | 
					//	{ "rename-session", "rs", op_rename_session },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
#define NOP (sizeof op_table / sizeof op_table[0])
 | 
					#define NOP (sizeof op_table / sizeof op_table[0])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										10
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								tmux.h
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: tmux.h,v 1.15 2007-09-26 18:50:49 nicm Exp $ */
 | 
					/* $Id: tmux.h,v 1.16 2007-09-27 09:15:58 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -466,10 +466,10 @@ int	 server_msg_dispatch(struct client *);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* server-fn.c */
 | 
					/* server-fn.c */
 | 
				
			||||||
void	 server_write_message(struct client *, const char *, ...);
 | 
					void	 server_write_message(struct client *, const char *, ...);
 | 
				
			||||||
void	 server_write_client(struct client *, u_int, void *, size_t);
 | 
					void	 server_write_client(struct client *, enum hdrtype, void *, size_t);
 | 
				
			||||||
void	 server_write_client2(
 | 
					void	 server_write_client2(
 | 
				
			||||||
	     struct client *, u_int, void *, size_t, void *, size_t);
 | 
						     struct client *, enum hdrtype, void *, size_t, void *, size_t);
 | 
				
			||||||
void	 server_write_clients(struct window *, u_int, void *, size_t);
 | 
					void	 server_write_clients(struct window *, enum hdrtype, void *, size_t);
 | 
				
			||||||
void	 server_window_changed(struct client *);
 | 
					void	 server_window_changed(struct client *);
 | 
				
			||||||
void	 server_draw_client(struct client *, u_int, u_int);
 | 
					void	 server_draw_client(struct client *, u_int, u_int);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -499,7 +499,7 @@ void	 local_output(struct buffer *, size_t);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* window.c */
 | 
					/* window.c */
 | 
				
			||||||
extern struct windows windows;
 | 
					extern struct windows windows;
 | 
				
			||||||
struct window	*window_create(const char *, u_int, u_int);
 | 
					struct window	*window_create(const char *, const char **, u_int, u_int);
 | 
				
			||||||
int		 window_index(struct windows *, struct window *, u_int *);
 | 
					int		 window_index(struct windows *, struct window *, u_int *);
 | 
				
			||||||
void		 window_add(struct windows *, struct window *);
 | 
					void		 window_add(struct windows *, struct window *);
 | 
				
			||||||
void		 window_remove(struct windows *, struct window *);
 | 
					void		 window_remove(struct windows *, struct window *);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										41
									
								
								window.c
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								window.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: window.c,v 1.10 2007-09-21 20:45:06 nicm Exp $ */
 | 
					/* $Id: window.c,v 1.11 2007-09-27 09:15:58 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -52,14 +52,14 @@ struct windows	windows;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* Create a new window. */
 | 
					/* Create a new window. */
 | 
				
			||||||
struct window *
 | 
					struct window *
 | 
				
			||||||
window_create(const char *cmd, u_int sx, u_int sy)
 | 
					window_create(const char *cmd, const char **environ, u_int sx, u_int sy)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct window	*w;
 | 
						struct window	*w;
 | 
				
			||||||
	struct winsize	 ws;
 | 
						struct winsize	 ws;
 | 
				
			||||||
	struct termios	 tio;
 | 
						struct termios	 tio;
 | 
				
			||||||
	struct sigaction act;
 | 
					 | 
				
			||||||
	int		 fd, mode;
 | 
						int		 fd, mode;
 | 
				
			||||||
	char		 pid[16], *ptr, *name;
 | 
						char		*ptr, *name;
 | 
				
			||||||
 | 
						const char     **entry;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	memset(&ws, 0, sizeof ws);
 | 
						memset(&ws, 0, sizeof ws);
 | 
				
			||||||
	ws.ws_col = sx;
 | 
						ws.ws_col = sx;
 | 
				
			||||||
@@ -73,40 +73,17 @@ window_create(const char *cmd, u_int sx, u_int sy)
 | 
				
			|||||||
	memcpy(&tio.c_cc, ttydefchars, sizeof tio.c_cc);
 | 
						memcpy(&tio.c_cc, ttydefchars, sizeof tio.c_cc);
 | 
				
			||||||
	cfsetspeed(&tio, TTYDEF_SPEED);
 | 
						cfsetspeed(&tio, TTYDEF_SPEED);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	xsnprintf(pid, sizeof pid, "%ld", (long) getpid());
 | 
					 | 
				
			||||||
	switch (forkpty(&fd, NULL, &tio, &ws)) {
 | 
						switch (forkpty(&fd, NULL, &tio, &ws)) {
 | 
				
			||||||
	case -1:
 | 
						case -1:
 | 
				
			||||||
		return (NULL);
 | 
							return (NULL);
 | 
				
			||||||
	case 0:
 | 
						case 0:
 | 
				
			||||||
		if (setenv("TMUX", pid, 1) != 0)
 | 
							for (entry = environ; *entry != NULL; entry++) {
 | 
				
			||||||
			fatal("setenv failed");
 | 
								if (putenv(*entry) != 0)
 | 
				
			||||||
		if (setenv("TERM", "screen", 1) != 0)
 | 
									fatal("putenv failed");
 | 
				
			||||||
			fatal("setenv failed");
 | 
							}
 | 
				
			||||||
 | 
							sigreset();
 | 
				
			||||||
		log_close();
 | 
							log_close();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		memset(&act, 0, sizeof act);
 | 
					 | 
				
			||||||
		sigemptyset(&act.sa_mask);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		act.sa_handler = SIG_DFL;
 | 
					 | 
				
			||||||
		if (sigaction(SIGPIPE, &act, NULL) != 0)
 | 
					 | 
				
			||||||
			fatal("sigaction failed");
 | 
					 | 
				
			||||||
		if (sigaction(SIGUSR1, &act, NULL) != 0)
 | 
					 | 
				
			||||||
			fatal("sigaction failed");
 | 
					 | 
				
			||||||
		if (sigaction(SIGUSR2, &act, NULL) != 0)
 | 
					 | 
				
			||||||
			fatal("sigaction failed");
 | 
					 | 
				
			||||||
		if (sigaction(SIGINT, &act, NULL) != 0)
 | 
					 | 
				
			||||||
			fatal("sigaction failed");
 | 
					 | 
				
			||||||
		if (sigaction(SIGTSTP, &act, NULL) != 0)
 | 
					 | 
				
			||||||
			fatal("sigaction failed");
 | 
					 | 
				
			||||||
		if (sigaction(SIGQUIT, &act, NULL) != 0)
 | 
					 | 
				
			||||||
			fatal("sigaction failed");
 | 
					 | 
				
			||||||
		if (sigaction(SIGWINCH, &act, NULL) != 0)
 | 
					 | 
				
			||||||
			fatal("sigaction failed");
 | 
					 | 
				
			||||||
		if (sigaction(SIGTERM, &act, NULL) != 0)
 | 
					 | 
				
			||||||
			fatal("sigaction failed");
 | 
					 | 
				
			||||||
		if (sigaction(SIGCHLD, &act, NULL) != 0)
 | 
					 | 
				
			||||||
			fatal("sigaction failed");
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		execl(_PATH_BSHELL, "sh", "-c", cmd, (char *) NULL);
 | 
							execl(_PATH_BSHELL, "sh", "-c", cmd, (char *) NULL);
 | 
				
			||||||
		fatal("execl failed");
 | 
							fatal("execl failed");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user