[net.bugs.4bsd] id AA27750; Wed, 21 Mar 84 20:21:16 GMT

sysman@glasgow.UUCP (03/23/84)

Date: Wed, 21 Mar 84 20:21:16 GMT
From: paisley!root (Paisley-Vax)
Message-Id: <8403212021.AA27750@paisley.UUCP>
Subject: Bugs in script(1).

From: Malcolm Crowe, Paisley College of Technology, 21 March 1984

The 4.2bsd script(1) is much improved through use of pseudo-ttys. However,
at Paisley we have noticed two problems:
(1)	occasionally get "Permission denied" messages when script starts up.
This happens if someone (root?) has left one side of a pty in read-only mode.
(2)	if user leaves a stopped (or background) process when exiting from
the script shell, the terminal hangs:
	% script
	Script started, file is typescript
	% cat
	^X
	Stopped
	% ^Z
	There are stopped jobs
	% ^Z
(hangs)

Changes to /usr/src/ucb/script.c version 4.5 (Berkeley):

100a101,106
> /* for periodic wakeups to see if the pty has been closed: see below */
> snooze()
> {
> 	alarm(5);
> }
> 
105c111,119
< 	if (wait3(&status, WNOHANG, 0) != child)
---
> 	if (wait3(&status, WNOHANG, 0) != child) {
> 	/* Almost certainly this has happened because the shell has
> 	 * exited. On return, if no other processes are around on the pty,
> 	 * dooutput() will finish up and exit. But in case there are
> 	 * background or stopped processes we set an alarm to wake us up
> 	 * every 5 seconds to see if the pty has been closed	
> 	 */
> 		signal(SIGALRM,snooze);
> 		alarm(5);
106a121
> 	}
193a209,217
> 	/* check that both ends of the pty are accessible */
> 				register int k=strlen("/dev/");
> 				line[k]='t';
> 				if (access(line,6)) {
> 					line[k]=c;
> 					close(master);
> 					goto reject;
> 				}
> 				line[k]=c;
200a225
> 	reject: ;