mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	If pgrp fails in osdep_get_cwd, try sid. Fixes eg cat foo|less. From Balazs
Kezes.
This commit is contained in:
		@@ -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);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user