Changeset View
Changeset View
Standalone View
Standalone View
head/libexec/getty/main.c
Show First 20 Lines • Show All 246 Lines • ▼ Show 20 Lines | if (IC) { | ||||
if (getty_chat(IC, CT, DC) > 0) { | if (getty_chat(IC, CT, DC) > 0) { | ||||
syslog(LOG_ERR, "modem init problem on %s", ttyn); | syslog(LOG_ERR, "modem init problem on %s", ttyn); | ||||
(void)tcsetattr(STDIN_FILENO, TCSANOW, &tmode); | (void)tcsetattr(STDIN_FILENO, TCSANOW, &tmode); | ||||
exit(1); | exit(1); | ||||
} | } | ||||
} | } | ||||
if (AC) { | if (AC) { | ||||
int i, rfds; | fd_set rfds; | ||||
struct timeval to; | struct timeval to; | ||||
int i; | |||||
rfds = 1 << 0; /* FD_SET */ | FD_ZERO(&rfds); | ||||
FD_SET(0, &rfds); | |||||
to.tv_sec = RT; | to.tv_sec = RT; | ||||
to.tv_usec = 0; | to.tv_usec = 0; | ||||
i = select(32, (fd_set*)&rfds, (fd_set*)NULL, | i = select(32, &rfds, NULL, NULL, RT ? &to : NULL); | ||||
(fd_set*)NULL, RT ? &to : NULL); | |||||
if (i < 0) { | if (i < 0) { | ||||
syslog(LOG_ERR, "select %s: %m", ttyn); | syslog(LOG_ERR, "select %s: %m", ttyn); | ||||
} else if (i == 0) { | } else if (i == 0) { | ||||
syslog(LOG_NOTICE, "recycle tty %s", ttyn); | syslog(LOG_NOTICE, "recycle tty %s", ttyn); | ||||
(void)tcsetattr(STDIN_FILENO, TCSANOW, &tmode); | (void)tcsetattr(STDIN_FILENO, TCSANOW, &tmode); | ||||
exit(0); /* recycle for init */ | exit(0); /* recycle for init */ | ||||
} | } | ||||
i = getty_chat(AC, CT, DC); | i = getty_chat(AC, CT, DC); | ||||
▲ Show 20 Lines • Show All 432 Lines • ▼ Show 20 Lines | prompt(void) | ||||
if (CO) | if (CO) | ||||
putchr('\n'); | putchr('\n'); | ||||
} | } | ||||
static char * | static char * | ||||
get_line(int fd) | get_line(int fd) | ||||
{ | { | ||||
int i = 0; | size_t i = 0; | ||||
static char linebuf[512]; | static char linebuf[512]; | ||||
/* | /* | ||||
* This is certainly slow, but it avoids having to include | * This is certainly slow, but it avoids having to include | ||||
* stdio.h unnecessarily. Issue files should be small anyway. | * stdio.h unnecessarily. Issue files should be small anyway. | ||||
*/ | */ | ||||
while (i < (sizeof linebuf - 3) && read(fd, linebuf+i, 1)==1) { | while (i < (sizeof linebuf - 3) && read(fd, linebuf+i, 1)==1) { | ||||
if (linebuf[i] == '\n') { | if (linebuf[i] == '\n') { | ||||
▲ Show 20 Lines • Show All 97 Lines • Show Last 20 Lines |