[PATCH] cu/tip leaves tty in exclusive mode

From: Bruce M Simpson <bms_at_incunabulum.net>
Date: Tue, 29 Apr 2008 02:35:46 +0100
Hi,

I think I saw a bug. I have an app which creates ptys on its own. I 
connect to them manually with cu -l.

It appears that cu doesn't clean up after itself... this is a quick fix
BMS

diff -urN /usr/src/usr.bin/tip/tip/cmds.c tip/cmds.c
--- /usr/src/usr.bin/tip/tip/cmds.c	2003-04-06 09:30:25.000000000 +0100
+++ tip/cmds.c	2008-04-29 02:31:28.000000000 +0100
_at__at_ -662,6 +662,7 _at__at_
 	daemon_uid();
 	(void)uu_unlock(uucplock);
 	unraw();
+	unexcl();
 	exit(0);
 }
 
diff -urN /usr/src/usr.bin/tip/tip/tip.c tip/tip.c
--- /usr/src/usr.bin/tip/tip/tip.c	2003-04-06 09:30:25.000000000 +0100
+++ tip/tip.c	2008-04-29 02:28:23.000000000 +0100
_at__at_ -322,6 +322,15 _at__at_
 	tcsetattr(0, TCSADRAIN, &defterm);
 }
 
+/*
+ * give up exclusive tty access
+ */
+void
+unexcl()
+{
+	ioctl(FD, TIOCNXCL, 0);
+}
+
 static	jmp_buf promptbuf;
 
 /*
diff -urN /usr/src/usr.bin/tip/tip/tip.h tip/tip.h
--- /usr/src/usr.bin/tip/tip/tip.h	2004-05-06 14:25:09.000000000 +0100
+++ tip/tip.h	2008-04-29 02:28:37.000000000 +0100
_at__at_ -308,6 +308,7 _at__at_
 void	transfer(char *buf, int fd, char *eofchars);
 void	transmit(FILE *fd, char *eofchars, char *command);
 void	ttysetup(int _speed);
+void	unexcl(void);
 void	unraw(void);
 void	user_uid(void);
 void	vinit(void);
diff -urN /usr/src/usr.bin/tip/tip/uucplock.c tip/uucplock.c
--- /usr/src/usr.bin/tip/tip/uucplock.c	2001-12-20 14:25:46.000000000 +0000
+++ tip/uucplock.c	2008-04-29 02:32:44.000000000 +0100
_at__at_ -131,5 +131,6 _at__at_
 	char tbuf[sizeof(_PATH_LOCKDIRNAME) + MAXNAMLEN];
 
 	(void)snprintf(tbuf, sizeof tbuf, _PATH_LOCKDIRNAME, ttyname);
+	unexcl();
 	return(unlink(tbuf));
 }
Received on Mon Apr 28 2008 - 23:50:59 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:30 UTC