summaryrefslogtreecommitdiffstats
path: root/libexec/getty
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2016-02-26 18:52:06 +0000
committerpfg <pfg@FreeBSD.org>2016-02-26 18:52:06 +0000
commit1e58db1a6c76ca73c632577bb27f44e7526bad6a (patch)
tree25ec41b6807271eae4d4773ddbdd8ca7ad127516 /libexec/getty
parentb1abdb4699cc8a275611ec585bd8bf52c5a9c569 (diff)
downloadFreeBSD-src-1e58db1a6c76ca73c632577bb27f44e7526bad6a.zip
FreeBSD-src-1e58db1a6c76ca73c632577bb27f44e7526bad6a.tar.gz
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)
Diffstat (limited to 'libexec/getty')
-rw-r--r--libexec/getty/subr.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/libexec/getty/subr.c b/libexec/getty/subr.c
index 992280a..5ce03bd 100644
--- a/libexec/getty/subr.c
+++ b/libexec/getty/subr.c
@@ -38,14 +38,16 @@ static const char rcsid[] =
/*
* Melbourne getty.
*/
-#include <stdlib.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/param.h>
#include <sys/time.h>
+
+#include <poll.h>
+#include <stdlib.h>
+#include <string.h>
#include <syslog.h>
+#include <termios.h>
+#include <unistd.h>
#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) {
OpenPOWER on IntegriCloud