Discussion:
patch for pane_current_path on solaris
J Raynor
2014-08-30 23:00:44 UTC
Permalink
pane_current_path on solaris doesn't work. I only have access to
solaris 11, so I can't tell if this is a new problem with that version
or if it hasn't worked for a while.

I've attached a patch that fixes the problem, but I can't test on
previous versions of solaris.

In osdep-sunos.c, osdep_get_cwd calls tcgetpgrp to get the pgrp.
tcgetpgrp fails because (on solaris) the caller has to be in the
foreground process group of the terminal it's querying. The TIOCGPGRP
ioctl doesn't have this restriction. But it needs the slave side of
the pty, and the fd passed in is the master side. This can be worked
around with ptsname.
Nicholas Marriott
2014-10-02 08:26:16 UTC
Permalink
Applied this, we'll see if anyone complains it breaks older Solaris and
if it does think again. Cheers
Post by J Raynor
pane_current_path on solaris doesn't work. I only have access to
solaris 11, so I can't tell if this is a new problem with that version
or if it hasn't worked for a while.
I've attached a patch that fixes the problem, but I can't test on
previous versions of solaris.
In osdep-sunos.c, osdep_get_cwd calls tcgetpgrp to get the pgrp.
tcgetpgrp fails because (on solaris) the caller has to be in the
foreground process group of the terminal it's querying. The TIOCGPGRP
ioctl doesn't have this restriction. But it needs the slave side of
the pty, and the fd passed in is the master side. This can be worked
around with ptsname.
diff --git a/osdep-sunos.c b/osdep-sunos.c
index fd644f5..f132f4d 100644
--- a/osdep-sunos.c
+++ b/osdep-sunos.c
@@ -69,10 +69,21 @@ osdep_get_cwd(int fd)
{
static char target[MAXPATHLEN + 1];
char *path;
+ const char *ttypath;
ssize_t n;
pid_t pgrp;
+ int retval, ttyfd;
- if ((pgrp = tcgetpgrp(fd)) == -1)
+ if ((ttypath = ptsname(fd)) == NULL)
+ return (NULL);
+
+ if ((ttyfd = open(ttypath, O_RDONLY|O_NOCTTY)) == -1)
+ return (NULL);
+
+ retval = ioctl(ttyfd, TIOCGPGRP, &pgrp);
+ close(ttyfd);
+
+ if (retval == -1)
return (NULL);
xasprintf(&path, "/proc/%u/path/cwd", (u_int) pgrp);
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds. Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
tmux-users mailing list
https://lists.sourceforge.net/lists/listinfo/tmux-users
Loading...