2 * TNET A server program for MINIX which implements the TCP/IP
3 * suite of networking protocols. It is based on the
4 * TCP/IP code written by Phil Karn et al, as found in
5 * his NET package for Packet Radio communications.
7 * Handle the TERMINAL module.
9 * Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
10 * Michael Temari, <temari@temari.ae.ge.com>
12 * 07/29/92 MT Telnet options hack which seems to work okay
13 * 01/12/93 MT Better telnet options processing instead of hack
15 #include <sys/types.h>
28 _PROTOTYPE(void sig_done
, (int sig
));
30 static char buff
[4096];
36 telopt(1, WILL
, TELOPT_SGA
);
37 telopt(1, DO
, TELOPT_SGA
);
38 telopt(1, WILL
, TELOPT_BINARY
);
39 telopt(1, DO
, TELOPT_BINARY
);
40 telopt(1, WILL
, TELOPT_ECHO
);
41 telopt(1, DO
, TELOPT_WINCH
);
44 static int io_done
= 0;
46 void term_inout(pty_fd
)
53 sigemptyset(&sa
.sa_mask
);
55 sa
.sa_handler
= sig_done
;
56 sigaction(SIGALRM
, &sa
, (struct sigaction
*) NULL
);
58 if ((pid
= fork()) == -1) {
59 sprintf(buff
, "telnetd: fork() failed: %s\r\n", strerror(errno
));
60 (void) write(1, buff
, strlen(buff
));
64 /* network -> login process */
65 while (!io_done
&& (i
= read(0, buff
, sizeof(buff
))) > 0) {
66 tel_in(pty_fd
, 1, buff
, i
);
68 /* EOF, kill opposite number and exit. */
69 (void) kill(pid
, SIGKILL
);
71 /* login process -> network */
72 while ((i
= read(pty_fd
, buff
, sizeof(buff
))) > 0) {
75 /* EOF, alert opposite number and exit. */
76 (void) kill(getppid(), SIGALRM
);
85 alarm(1); /* there is always a chance... */