diff --git a/control.c b/control.c index 91972261..b5ec6bdb 100644 --- a/control.c +++ b/control.c @@ -79,6 +79,15 @@ control_write(struct client *c, const char *fmt, ...) server_push_stdout(c); } +/* Write a buffer, adding a terminal newline. Empties buffer. */ +void +control_write_buffer(struct client *c, struct evbuffer *buffer) +{ + evbuffer_add_buffer(c->stdout_data, buffer); + evbuffer_add(c->stdout_data, "\n", 1); + server_push_stdout(c); +} + /* Control input callback. Read lines and fire commands. */ void control_callback(struct client *c, int closed, unused void *data) diff --git a/osdep-openbsd.c b/osdep-openbsd.c index 4fb75bff..402b501c 100644 --- a/osdep-openbsd.c +++ b/osdep-openbsd.c @@ -137,10 +137,12 @@ error: char* osdep_get_cwd(pid_t pid) { - int name[] = { CTL_KERN, KERN_PROC_CWD, (int)pid }; + int name[] = { CTL_KERN, KERN_PROC_CWD, 0 }; static char path[MAXPATHLEN]; size_t pathlen = sizeof path; + if ((name[2] = tcgetpgrp(fd)) == -1) + return (NULL); if (sysctl(name, 3, path, &pathlen, NULL, 0) != 0) return (NULL); return (path); diff --git a/tmux.h b/tmux.h index 9374012b..83bcb878 100644 --- a/tmux.h +++ b/tmux.h @@ -2217,6 +2217,7 @@ void clear_signals(int); /* control.c */ void control_callback(struct client *, int, void*); void printflike2 control_write(struct client *, const char *, ...); +void control_write_buffer(struct client *, struct evbuffer *); /* control-notify.c */ void control_notify_window_layout_changed(struct window *);