From 3e95714e815457b8e2c95138f9242701e3c08434 Mon Sep 17 00:00:00 2001 From: mycroft Date: Thu, 27 Apr 1995 21:22:19 +0000 Subject: Use POSIX signal and tty semantics. --- atc/main.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'atc/main.c') diff --git a/atc/main.c b/atc/main.c index a75a43f2..9f2c0cef 100644 --- a/atc/main.c +++ b/atc/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.3 1995/03/21 15:04:24 cgd Exp $ */ +/* $NetBSD: main.c,v 1.4 1995/04/27 21:22:25 mycroft Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -55,7 +55,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: main.c,v 1.3 1995/03/21 15:04:24 cgd Exp $"; +static char rcsid[] = "$NetBSD: main.c,v 1.4 1995/04/27 21:22:25 mycroft Exp $"; #endif #endif /* not lint */ @@ -70,6 +70,7 @@ main(ac, av) int f_printpath = 0; char *file = NULL; char *name, *ptr; + struct sigaction sa; #ifdef BSD struct itimerval itv; #endif @@ -164,25 +165,19 @@ main(ac, av) signal(SIGHUP, log_score); signal(SIGTERM, log_score); -#ifdef BSD - ioctl(fileno(stdin), TIOCGETP, &tty_start); - bcopy(&tty_start, &tty_new, sizeof(tty_new)); - tty_new.sg_flags |= CBREAK; - tty_new.sg_flags &= ~ECHO; - ioctl(fileno(stdin), TIOCSETP, &tty_new); -#endif - -#ifdef SYSV - ioctl(fileno(stdin), TCGETA, &tty_start); - bcopy(&tty_start, &tty_new, sizeof(tty_new)); - tty_new.c_lflag &= ~ICANON; - tty_new.c_lflag &= ~ECHO; + tcgetattr(fileno(stdin), &tty_start); + tty_new = tty_start; + tty_new.c_lflag &= ~(ICANON|ECHO); tty_new.c_cc[VMIN] = 1; tty_new.c_cc[VTIME] = 0; - ioctl(fileno(stdin), TCSETAW, &tty_new); -#endif - - signal(SIGALRM, update); + tcsetattr(fileno(stdin), TCSADRAIN, &tty_new); + + sa.sa_handler = update; + sigemptyset(&sa.sa_mask); + sigaddset(&sa.sa_mask, SIGALRM); + sigaddset(&sa.sa_mask, SIGINT); + sa.sa_flags = 0; + sigaction(SIGALRM, &sa, (struct sigaction *)0); #ifdef BSD itv.it_value.tv_sec = 0; -- cgit v1.2.3-56-ge451