From 1f5e6e35d5046693f0ef5ec76535f517757b7122 Mon Sep 17 00:00:00 2001 From: Tiago Cunha Date: Wed, 11 Jul 2012 19:37:32 +0000 Subject: Sync OpenBSD patchset 1151: Make command exec functions return an enum rather than -1/0/1 values and add a new value to mean "leave client running but don't attach" to fix problems with using some commands in a command sequence. Most of the work by Thomas Adam, problem reported by "jspenguin" on SF bug 3535531. --- cmd-pipe-pane.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'cmd-pipe-pane.c') diff --git a/cmd-pipe-pane.c b/cmd-pipe-pane.c index 5c8b6a0c..d2d85003 100644 --- a/cmd-pipe-pane.c +++ b/cmd-pipe-pane.c @@ -31,7 +31,7 @@ * Open pipe to redirect pane output. If already open, close first. */ -int cmd_pipe_pane_exec(struct cmd *, struct cmd_ctx *); +enum cmd_retval cmd_pipe_pane_exec(struct cmd *, struct cmd_ctx *); void cmd_pipe_pane_error_callback(struct bufferevent *, short, void *); @@ -45,7 +45,7 @@ const struct cmd_entry cmd_pipe_pane_entry = { cmd_pipe_pane_exec }; -int +enum cmd_retval cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx) { struct args *args = self->args; @@ -55,7 +55,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx) int old_fd, pipe_fd[2], null_fd; if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL) - return (-1); + return (CMD_RETURN_ERROR); c = cmd_find_client(ctx, NULL); /* Destroy the old pipe. */ @@ -68,7 +68,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx) /* If no pipe command, that is enough. */ if (args->argc == 0 || *args->argv[0] == '\0') - return (0); + return (CMD_RETURN_NORMAL); /* * With -o, only open the new pipe if there was no previous one. This @@ -77,19 +77,19 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx) * bind ^p pipep -o 'cat >>~/output' */ if (args_has(self->args, 'o') && old_fd != -1) - return (0); + return (CMD_RETURN_NORMAL); /* Open the new pipe. */ if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe_fd) != 0) { ctx->error(ctx, "socketpair error: %s", strerror(errno)); - return (-1); + return (CMD_RETURN_ERROR); } /* Fork the child. */ switch (fork()) { case -1: ctx->error(ctx, "fork error: %s", strerror(errno)); - return (-1); + return (CMD_RETURN_ERROR); case 0: /* Child process. */ close(pipe_fd[0]); @@ -126,7 +126,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx) bufferevent_enable(wp->pipe_event, EV_WRITE); setblocking(wp->pipe_fd, 0); - return (0); + return (CMD_RETURN_NORMAL); } } -- cgit