Exemple #1
0
RETSIGTYPE
sig_tstop(int i)	/* SIGTSTP handler */

{
    /* move to the lower left */
    screen_end();
    fflush(stdout);

    /* default the signal handler action */
    set_signal(SIGTSTP, SIG_DFL);

    /* unblock the TSTP signal */
    release_signal(SIGTSTP);

    /* send ourselves a TSTP to stop the process */
    (void) kill(0, SIGTSTP);

    /* reset the signal handler */
    set_signal(SIGTSTP, sig_tstop);

    /* reinit screen */
    screen_reinit();

    /* jump back to a known place in the main loop */
    longjmp(jmp_int, JMP_RESUME);

    /* NOTREACHED */
}
Exemple #2
0
enum cmd_retval
cmd_respawn_pane_exec(struct cmd *self, struct cmd_q *cmdq)
{
	struct args		*args = self->args;
	struct winlink		*wl;
	struct window		*w;
	struct window_pane	*wp;
	struct session		*s;
	struct environ		*env;
	const char		*path;
	char			*cause;
	u_int			 idx;
	struct environ_entry	*envent;

	if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp)) == NULL)
		return (CMD_RETURN_ERROR);
	w = wl->window;

	if (!args_has(self->args, 'k') && wp->fd != -1) {
		if (window_pane_index(wp, &idx) != 0)
			fatalx("index not found");
		cmdq_error(cmdq, "pane still active: %s:%d.%u",
		    s->name, wl->idx, idx);
		return (CMD_RETURN_ERROR);
	}

	env = environ_create();
	environ_copy(global_environ, env);
	environ_copy(s->environ, env);
	server_fill_environ(s, env);

	window_pane_reset_mode(wp);
	screen_reinit(&wp->base);
	input_init(wp);

	path = NULL;
	if (cmdq->client != NULL && cmdq->client->session == NULL)
		envent = environ_find(cmdq->client->environ, "PATH");
	else
		envent = environ_find(s->environ, "PATH");
	if (envent != NULL)
		path = envent->value;

	if (window_pane_spawn(wp, args->argc, args->argv, path, NULL, -1, env,
	    s->tio, &cause) != 0) {
		cmdq_error(cmdq, "respawn pane failed: %s", cause);
		free(cause);
		environ_free(env);
		return (CMD_RETURN_ERROR);
	}
	wp->flags |= PANE_REDRAW;
	server_status_window(w);

	environ_free(env);
	return (CMD_RETURN_NORMAL);
}
Exemple #3
0
/* Create a new screen. */
void
screen_init(struct screen *s, u_int sx, u_int sy, u_int hlimit)
{
	s->grid = grid_create(sx, sy, hlimit);
	s->title = xstrdup("");

	s->cstyle = 0;
	s->ccolour = xstrdup("");
	s->tabs = NULL;

	screen_reinit(s);
}
int
cmd_respawn_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
{
	struct args		*args = self->args;
	struct winlink		*wl;
	struct window		*w;
	struct window_pane	*wp;
	struct session		*s;
	struct environ		 env;
	const char		*cmd;
	char			*cause;
	u_int			 idx;

	if ((wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp)) == NULL)
		return (-1);
	w = wl->window;

	if (!args_has(self->args, 'k') && wp->fd != -1) {
		if (window_pane_index(wp, &idx) != 0)
			fatalx("index not found");
		ctx->error(ctx, "pane still active: %s:%u.%u",
		    s->name, wl->idx, idx);
		return (-1);
	}

	environ_init(&env);
	environ_copy(&global_environ, &env);
	environ_copy(&s->environ, &env);
	server_fill_environ(s, &env);

	window_pane_reset_mode(wp);
	screen_reinit(&wp->base);
	input_init(wp);

	if (args->argc != 0)
		cmd = args->argv[0];
	else
		cmd = NULL;
	if (window_pane_spawn(wp, cmd, NULL, NULL, &env, s->tio, &cause) != 0) {
		ctx->error(ctx, "respawn pane failed: %s", cause);
		xfree(cause);
		environ_free(&env);
		return (-1);
	}
	wp->flags |= PANE_REDRAW;
	server_status_window(w);

	environ_free(&env);
	return (0);
}
Exemple #5
0
static enum cmd_retval
cmd_respawn_pane_exec(struct cmd *self, struct cmdq_item *item)
{
	struct args		*args = self->args;
	struct winlink		*wl = item->target.wl;
	struct window		*w = wl->window;
	struct window_pane	*wp = item->target.wp;
	struct session		*s = item->target.s;
	struct environ		*env;
	const char		*path;
	char			*cause;
	u_int			 idx;
	struct environ_entry	*envent;

	if (!args_has(self->args, 'k') && wp->fd != -1) {
		if (window_pane_index(wp, &idx) != 0)
			fatalx("index not found");
		cmdq_error(item, "pane still active: %s:%d.%u",
		    s->name, wl->idx, idx);
		return (CMD_RETURN_ERROR);
	}

	window_pane_reset_mode(wp);
	screen_reinit(&wp->base);
	input_init(wp);

	path = NULL;
	if (item->client != NULL && item->client->session == NULL)
		envent = environ_find(item->client->environ, "PATH");
	else
		envent = environ_find(s->environ, "PATH");
	if (envent != NULL)
		path = envent->value;

	env = environ_for_session(s, 0);
	if (window_pane_spawn(wp, args->argc, args->argv, path, NULL, NULL, env,
	    s->tio, &cause) != 0) {
		cmdq_error(item, "respawn pane failed: %s", cause);
		free(cause);
		environ_free(env);
		return (CMD_RETURN_ERROR);
	}
	environ_free(env);

	wp->flags |= PANE_REDRAW;
	server_status_window(w);

	return (CMD_RETURN_NORMAL);
}
Exemple #6
0
/* Create a new screen. */
void
screen_init(struct screen *s, u_int sx, u_int sy, u_int hlimit)
{
	char hn[MAXHOSTNAMELEN];

	s->grid = grid_create(sx, sy, hlimit);

	if (gethostname(hn, MAXHOSTNAMELEN) == 0)
		s->title = xstrdup(hn);
	else
		s->title = xstrdup("");

	s->tabs = NULL;

	screen_reinit(s);
}
Exemple #7
0
/* Create a new screen. */
void
screen_init(struct screen *s, u_int sx, u_int sy, u_int hlimit)
{
	char host[HOST_NAME_MAX];

	s->grid = grid_create(sx, sy, hlimit);

	if (gethostname(host, HOST_NAME_MAX) == 0)
		s->title = xstrdup(host);
	else
		s->title = xstrdup("");

	s->cstyle = 0;
	s->ccolour = xstrdup("");
	s->tabs = NULL;

	screen_reinit(s);
}