The existing code allocated 2 bytes (char*), but gtty() needs 6 bytes (struct sgttyb), so isatty() smashed the stack and corrupted its return address, probably causing SIGBUS or SIGSEGV. Fix by switching to TIOCGETD, which needs 2 bytes. TIOCGETD isn't in the manual for tty(4), but does appear in https://minnie.tuhs.org//cgi-bin/utree.pl?file=V7/usr/sys/dev/tty.c This fixes hilo_c.pdpv7 and hilo_mod.pdpv7 in simh-pdp11.
		
			
				
	
	
		
			8 lines
		
	
	
	
		
			125 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			8 lines
		
	
	
	
		
			125 B
		
	
	
	
		
			C
		
	
	
	
	
	
| int isatty(int fd)
 | |
| {
 | |
|     unsigned u;
 | |
| 
 | |
|     if (ioctl(fd, /*TIOCGETD*/(('t'<<8)|0), &u) < 0)
 | |
|         return 0;
 | |
|     return 1;
 | |
| }
 |