mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:26:05 +00:00 
			
		
		
		
	Fill in the tty name in SunOS's forkpty compat, and use it in osdep_getname.
From Todd Carson. Tweaked by me to nuke (void) casts. Say no to lint appeasement! ;-)
This commit is contained in:
		@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: forkpty-sunos.c,v 1.8 2009-09-20 18:31:16 nicm Exp $ */
 | 
					/* $Id: forkpty-sunos.c,v 1.9 2009-10-15 07:11:25 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -27,7 +27,7 @@
 | 
				
			|||||||
#include "tmux.h"
 | 
					#include "tmux.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pid_t
 | 
					pid_t
 | 
				
			||||||
forkpty(int *master, unused char *name, struct termios *tio, struct winsize *ws)
 | 
					forkpty(int *master, char *name, struct termios *tio, struct winsize *ws)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int	slave;
 | 
						int	slave;
 | 
				
			||||||
	char   *path;
 | 
						char   *path;
 | 
				
			||||||
@@ -42,6 +42,8 @@ forkpty(int *master, unused char *name, struct termios *tio, struct winsize *ws)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	if ((path = ptsname(*master)) == NULL)
 | 
						if ((path = ptsname(*master)) == NULL)
 | 
				
			||||||
		goto out;
 | 
							goto out;
 | 
				
			||||||
 | 
						if (name != NULL)
 | 
				
			||||||
 | 
							strlcpy(name, path, TTY_NAME_MAX);
 | 
				
			||||||
	if ((slave = open(path, O_RDWR|O_NOCTTY)) == -1)
 | 
						if ((slave = open(path, O_RDWR|O_NOCTTY)) == -1)
 | 
				
			||||||
		goto out;
 | 
							goto out;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: osdep-sunos.c,v 1.1 2009-10-14 10:14:21 nicm Exp $ */
 | 
					/* $Id: osdep-sunos.c,v 1.2 2009-10-15 07:11:25 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2009 Todd Carson <toc@daybefore.net>
 | 
					 * Copyright (c) 2009 Todd Carson <toc@daybefore.net>
 | 
				
			||||||
@@ -28,7 +28,7 @@
 | 
				
			|||||||
#include "tmux.h"
 | 
					#include "tmux.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
char *
 | 
					char *
 | 
				
			||||||
osdep_get_name(int fd, unused char *tty)
 | 
					osdep_get_name(int fd, char *tty)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct psinfo	 p;
 | 
						struct psinfo	 p;
 | 
				
			||||||
	struct stat	 st;
 | 
						struct stat	 st;
 | 
				
			||||||
@@ -37,18 +37,15 @@ osdep_get_name(int fd, unused char *tty)
 | 
				
			|||||||
	int		 f;
 | 
						int		 f;
 | 
				
			||||||
	pid_t		 pgrp;
 | 
						pid_t		 pgrp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((path = ptsname(fd)) == NULL)
 | 
						if ((f = open(tty, O_RDONLY)) < 0)
 | 
				
			||||||
		return (NULL);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if ((f = open(path, O_RDONLY)) < 0)
 | 
					 | 
				
			||||||
		return (NULL);
 | 
							return (NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((fstat(f, &st) != 0) ||
 | 
						if ((fstat(f, &st) != 0) ||
 | 
				
			||||||
	    (ioctl(f, TIOCGPGRP, &pgrp) != 0)) {
 | 
						    (ioctl(f, TIOCGPGRP, &pgrp) != 0)) {
 | 
				
			||||||
		(void) close(f);
 | 
							close(f);
 | 
				
			||||||
		return (NULL);
 | 
							return (NULL);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	(void) close(f);
 | 
						close(f);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	xasprintf(&path, "/proc/%hu/psinfo", pgrp);
 | 
						xasprintf(&path, "/proc/%hu/psinfo", pgrp);
 | 
				
			||||||
	f = open(path, O_RDONLY);
 | 
						f = open(path, O_RDONLY);
 | 
				
			||||||
@@ -57,7 +54,7 @@ osdep_get_name(int fd, unused char *tty)
 | 
				
			|||||||
		return (NULL);
 | 
							return (NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bytes = read(f, &p, sizeof(p));
 | 
						bytes = read(f, &p, sizeof(p));
 | 
				
			||||||
	(void) close(f);
 | 
						close(f);
 | 
				
			||||||
	if (bytes != sizeof(p))
 | 
						if (bytes != sizeof(p))
 | 
				
			||||||
		return (NULL);
 | 
							return (NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user