mirror of
https://github.com/tmux/tmux.git
synced 2024-11-10 13:48:48 +00:00
If pgrp fails in osdep_get_cwd, try sid. Fixes eg cat foo|less. From Balazs
Kezes.
This commit is contained in:
parent
4abc8f717a
commit
024846b4d8
@ -65,7 +65,7 @@ osdep_get_cwd(int fd)
|
||||
{
|
||||
static char target[MAXPATHLEN + 1];
|
||||
char *path;
|
||||
pid_t pgrp;
|
||||
pid_t pgrp, sid;
|
||||
ssize_t n;
|
||||
|
||||
if ((pgrp = tcgetpgrp(fd)) == -1)
|
||||
@ -74,6 +74,13 @@ osdep_get_cwd(int fd)
|
||||
xasprintf(&path, "/proc/%lld/cwd", (long long) pgrp);
|
||||
n = readlink(path, target, MAXPATHLEN);
|
||||
free(path);
|
||||
|
||||
if (n == -1 && ioctl(fd, TIOCGSID, &sid) != -1) {
|
||||
xasprintf(&path, "/proc/%lld/cwd", (long long) sid);
|
||||
n = readlink(path, target, MAXPATHLEN);
|
||||
free(path);
|
||||
}
|
||||
|
||||
if (n > 0) {
|
||||
target[n] = '\0';
|
||||
return (target);
|
||||
|
Loading…
Reference in New Issue
Block a user