From owner-svn-src-all@freebsd.org Fri Feb 26 18:52:07 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 858B2AB4D1B; Fri, 26 Feb 2016 18:52:07 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 531B17D4; Fri, 26 Feb 2016 18:52:07 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u1QIq6Ak073976; Fri, 26 Feb 2016 18:52:06 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u1QIq6vf073975; Fri, 26 Feb 2016 18:52:06 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201602261852.u1QIq6vf073975@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Fri, 26 Feb 2016 18:52:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r296104 - head/libexec/getty X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Feb 2016 18:52:07 -0000 Author: pfg Date: Fri Feb 26 18:52:06 2016 New Revision: 296104 URL: https://svnweb.freebsd.org/changeset/base/296104 Log: getty(8): Use poll(2) and nanosleep(2) instead of select(2). Sort headers while here. Obtained from: NetBSD (CVS Rev. 1.25 - 1.26) Modified: head/libexec/getty/subr.c Modified: head/libexec/getty/subr.c ============================================================================== --- head/libexec/getty/subr.c Fri Feb 26 16:18:47 2016 (r296103) +++ head/libexec/getty/subr.c Fri Feb 26 18:52:06 2016 (r296104) @@ -38,14 +38,16 @@ static const char rcsid[] = /* * Melbourne getty. */ -#include -#include -#include -#include #include #include #include + +#include +#include +#include #include +#include +#include #include "gettytab.h" #include "pathnames.h" @@ -633,24 +635,21 @@ portselector(void) const char * autobaud(void) { - int rfds; - struct timeval timeout; +struct pollfd set[1]; + struct timespec timeout; char c; const char *type = "9600-baud"; (void)tcflush(0, TCIOFLUSH); - rfds = 1 << 0; - timeout.tv_sec = 5; - timeout.tv_usec = 0; - if (select(32, (fd_set *)&rfds, (fd_set *)NULL, - (fd_set *)NULL, &timeout) <= 0) + set[0].fd = STDIN_FILENO; + set[0].events = POLLIN; + if (poll(set, 1, 5000) <= 0) return (type); if (read(STDIN_FILENO, &c, sizeof(char)) != sizeof(char)) return (type); timeout.tv_sec = 0; - timeout.tv_usec = 20; - (void) select(32, (fd_set *)NULL, (fd_set *)NULL, - (fd_set *)NULL, &timeout); + timeout.tv_nsec = 20000; + (void)nanosleep(&timeout, NULL); (void)tcflush(0, TCIOFLUSH); switch (c & 0377) {