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)
This commit is contained in:
parent
6bcf245ebc
commit
a3e4b9829e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=296104
@ -38,14 +38,16 @@ static const char rcsid[] =
|
|||||||
/*
|
/*
|
||||||
* Melbourne getty.
|
* Melbourne getty.
|
||||||
*/
|
*/
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <termios.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#include <poll.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
#include <termios.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "gettytab.h"
|
#include "gettytab.h"
|
||||||
#include "pathnames.h"
|
#include "pathnames.h"
|
||||||
@ -633,24 +635,21 @@ portselector(void)
|
|||||||
const char *
|
const char *
|
||||||
autobaud(void)
|
autobaud(void)
|
||||||
{
|
{
|
||||||
int rfds;
|
struct pollfd set[1];
|
||||||
struct timeval timeout;
|
struct timespec timeout;
|
||||||
char c;
|
char c;
|
||||||
const char *type = "9600-baud";
|
const char *type = "9600-baud";
|
||||||
|
|
||||||
(void)tcflush(0, TCIOFLUSH);
|
(void)tcflush(0, TCIOFLUSH);
|
||||||
rfds = 1 << 0;
|
set[0].fd = STDIN_FILENO;
|
||||||
timeout.tv_sec = 5;
|
set[0].events = POLLIN;
|
||||||
timeout.tv_usec = 0;
|
if (poll(set, 1, 5000) <= 0)
|
||||||
if (select(32, (fd_set *)&rfds, (fd_set *)NULL,
|
|
||||||
(fd_set *)NULL, &timeout) <= 0)
|
|
||||||
return (type);
|
return (type);
|
||||||
if (read(STDIN_FILENO, &c, sizeof(char)) != sizeof(char))
|
if (read(STDIN_FILENO, &c, sizeof(char)) != sizeof(char))
|
||||||
return (type);
|
return (type);
|
||||||
timeout.tv_sec = 0;
|
timeout.tv_sec = 0;
|
||||||
timeout.tv_usec = 20;
|
timeout.tv_nsec = 20000;
|
||||||
(void) select(32, (fd_set *)NULL, (fd_set *)NULL,
|
(void)nanosleep(&timeout, NULL);
|
||||||
(fd_set *)NULL, &timeout);
|
|
||||||
(void)tcflush(0, TCIOFLUSH);
|
(void)tcflush(0, TCIOFLUSH);
|
||||||
switch (c & 0377) {
|
switch (c & 0377) {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user