version 1.53, 2018/05/24 09:42:49 |
version 1.54, 2018/08/23 15:45:05 |
|
|
static void |
static void |
cmd_run_shell_print(struct job *job, const char *msg) |
cmd_run_shell_print(struct job *job, const char *msg) |
{ |
{ |
struct cmd_run_shell_data *cdata = job->data; |
struct cmd_run_shell_data *cdata = job_get_data(job); |
struct window_pane *wp = NULL; |
struct window_pane *wp = NULL; |
struct cmd_find_state fs; |
struct cmd_find_state fs; |
|
|
|
|
static void |
static void |
cmd_run_shell_callback(struct job *job) |
cmd_run_shell_callback(struct job *job) |
{ |
{ |
struct cmd_run_shell_data *cdata = job->data; |
struct cmd_run_shell_data *cdata = job_get_data(job); |
char *cmd = cdata->cmd, *msg, *line; |
struct bufferevent *event = job_get_event(job); |
|
char *cmd = cdata->cmd, *msg = NULL, *line; |
size_t size; |
size_t size; |
int retcode; |
int retcode, status; |
|
|
do { |
do { |
if ((line = evbuffer_readline(job->event->input)) != NULL) { |
if ((line = evbuffer_readline(event->input)) != NULL) { |
cmd_run_shell_print(job, line); |
cmd_run_shell_print(job, line); |
free(line); |
free(line); |
} |
} |
} while (line != NULL); |
} while (line != NULL); |
|
|
size = EVBUFFER_LENGTH(job->event->input); |
size = EVBUFFER_LENGTH(event->input); |
if (size != 0) { |
if (size != 0) { |
line = xmalloc(size + 1); |
line = xmalloc(size + 1); |
memcpy(line, EVBUFFER_DATA(job->event->input), size); |
memcpy(line, EVBUFFER_DATA(event->input), size); |
line[size] = '\0'; |
line[size] = '\0'; |
|
|
cmd_run_shell_print(job, line); |
cmd_run_shell_print(job, line); |
|
|
free(line); |
free(line); |
} |
} |
|
|
msg = NULL; |
status = job_get_status(job); |
if (WIFEXITED(job->status)) { |
if (WIFEXITED(status)) { |
if ((retcode = WEXITSTATUS(job->status)) != 0) |
if ((retcode = WEXITSTATUS(status)) != 0) |
xasprintf(&msg, "'%s' returned %d", cmd, retcode); |
xasprintf(&msg, "'%s' returned %d", cmd, retcode); |
} else if (WIFSIGNALED(job->status)) { |
} else if (WIFSIGNALED(status)) { |
retcode = WTERMSIG(job->status); |
retcode = WTERMSIG(status); |
xasprintf(&msg, "'%s' terminated by signal %d", cmd, retcode); |
xasprintf(&msg, "'%s' terminated by signal %d", cmd, retcode); |
} |
} |
if (msg != NULL) |
if (msg != NULL) |