diff options
author | brian <brian@FreeBSD.org> | 1997-11-11 12:28:02 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1997-11-11 12:28:02 +0000 |
commit | 90324e9327365460167787b036a8b4a6f37fe0e8 (patch) | |
tree | 17ac453ac7ccb7d06824fee93af8c4c53c6f6add /usr.sbin/pppctl | |
parent | 474d294d46696245d3ace21106015186dfde8a3e (diff) | |
download | FreeBSD-src-90324e9327365460167787b036a8b4a6f37fe0e8.zip FreeBSD-src-90324e9327365460167787b036a8b4a6f37fe0e8.tar.gz |
Poll the socket descriptor while in el_gets()
so that our display is scribbled over as we
requested.
Diffstat (limited to 'usr.sbin/pppctl')
-rw-r--r-- | usr.sbin/pppctl/pppctl.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/usr.sbin/pppctl/pppctl.c b/usr.sbin/pppctl/pppctl.c index ea5b115..e86033c 100644 --- a/usr.sbin/pppctl/pppctl.c +++ b/usr.sbin/pppctl/pppctl.c @@ -7,6 +7,7 @@ #include <netdb.h> #include <histedit.h> +#include <poll.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> @@ -128,6 +129,40 @@ Receive(int fd, unsigned TimeoutVal, int display) return Result; } +static int data = -1; + +static void +check_fd(int sig) +{ + if (data != -1) { + struct pollfd p; + static char buf[LINELEN]; + + p.fd = data; + p.events = POLLIN|POLLPRI; + p.revents = p.events|POLLOUT; + if (poll(&p, 1, 0) > 0) + write(1, buf, read(data, buf, sizeof buf)); + } +} + +static const char * +smartgets(EditLine *e, int *count, int fd) +{ + const char *result; + /* struct itimerval it; */ + + data = fd; + signal(SIGALRM, check_fd); + ualarm(500000, 500000); + result = el_gets(e, count); + ualarm(0,0); + signal(SIGALRM, SIG_DFL); + data = -1; + + return result; +} + int main(int argc, char **argv) { @@ -307,7 +342,7 @@ main(int argc, char **argv) el_set(edit, EL_EDITOR, "emacs"); el_set(edit, EL_SIGNAL, 1); el_set(edit, EL_HIST, history, (const char *)hist); - while ((l = el_gets(edit, &len))) { + while ((l = smartgets(edit, &len, fd))) { if (len > 1) history(hist, H_ENTER, l); write(fd, l, len); |