Hot answers tagged

1

As it is for a UPS, I imagine you can afford to poll the modem signals every 10 seconds or so (from freebsd tty(4)): int state; if(ioctl(fd, TIOCMGET, &state)...) if(state & TIOCM_DTR)... However, if you want to be notified immediately of changes in exactly one modem signal, namely DCD, you can set the tty flags to clear CLOCAL (see termios), then ...


1

zero is a legal file descriptor. The openpty call will (like open) return a positive integer (zero or more). They return -1 on error. A successful call returns a new (previously unused) file descriptor. You could get this result you had closed stdin (also legal, done occasionally in daemon/service code).



Only top voted, non community-wiki answers of a minimum length are eligible