mirror of
https://github.com/tmux/tmux.git
synced 2024-12-24 18:21:33 +00:00
osdep_get_cwd for NetBSD, from Leonardo Taccari.
This commit is contained in:
parent
1ed994a6c8
commit
6cf2f74fe9
@ -23,10 +23,13 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <event.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
#define is_runnable(p) \
|
||||
((p)->p_stat == LSRUN || (p)->p_stat == SIDL)
|
||||
#define is_stopped(p) \
|
||||
@ -129,6 +132,22 @@ error:
|
||||
char *
|
||||
osdep_get_cwd(int fd)
|
||||
{
|
||||
static char target[PATH_MAX + 1];
|
||||
char *path;
|
||||
pid_t pgrp;
|
||||
ssize_t n;
|
||||
|
||||
if ((pgrp = tcgetpgrp(fd)) == -1)
|
||||
return (NULL);
|
||||
|
||||
xasprintf(&path, "/proc/%lld/cwd", (long long) pgrp);
|
||||
n = readlink(path, target, sizeof(target) - 1);
|
||||
free(path);
|
||||
if (n > 0) {
|
||||
target[n] = '\0';
|
||||
return (target);
|
||||
}
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user