version 1.22, 2003/10/15 22:33:18 |
version 1.23, 2004/05/26 18:17:59 |
|
|
int disc = TTYDISC; /* tip normally runs this way */ |
int disc = TTYDISC; /* tip normally runs this way */ |
void intprompt(); |
void intprompt(); |
void timeout(); |
void timeout(); |
void cleanup(); |
void cleanup(int); |
char PNbuf[256]; /* This limits the size of a number */ |
char PNbuf[256]; /* This limits the size of a number */ |
|
|
int |
int |
|
|
(void)signal(SIGQUIT, cleanup); |
(void)signal(SIGQUIT, cleanup); |
(void)signal(SIGHUP, cleanup); |
(void)signal(SIGHUP, cleanup); |
(void)signal(SIGTERM, cleanup); |
(void)signal(SIGTERM, cleanup); |
|
(void)signal(SIGCHLD, SIG_IGN); |
|
|
if ((i = hunt(system)) == 0) { |
if ((i = hunt(system)) == 0) { |
printf("all ports busy\n"); |
printf("all ports busy\n"); |
|
|
i = fcntl(FD, F_GETFL); |
i = fcntl(FD, F_GETFL); |
if (i == -1) { |
if (i == -1) { |
perror("fcntl"); |
perror("fcntl"); |
cleanup(); |
cleanup(0); |
} |
} |
i = fcntl(FD, F_SETFL, i & ~O_NONBLOCK); |
i = fcntl(FD, F_SETFL, i & ~O_NONBLOCK); |
if (i == -1) { |
if (i == -1) { |
perror("fcntl"); |
perror("fcntl"); |
cleanup(); |
cleanup(0); |
} |
} |
|
|
tcgetattr(0, &defterm); |
tcgetattr(0, &defterm); |
|
|
* so, fork one process for local side and one for remote. |
* so, fork one process for local side and one for remote. |
*/ |
*/ |
printf(cumode ? "Connected\r\n" : "\07connected\r\n"); |
printf(cumode ? "Connected\r\n" : "\07connected\r\n"); |
if ((pid = fork())) |
tipin_pid = getpid(); |
|
if ((tipout_pid = fork())) |
tipin(); |
tipin(); |
else |
else |
tipout(); |
tipout(); |
|
|
} |
} |
|
|
void |
void |
cleanup() |
cleanup(int signo) |
{ |
{ |
|
|
daemon_uid(); |
daemon_uid(); |
|
|
if (odisc) |
if (odisc) |
ioctl(0, TIOCSETD, (char *)&odisc); |
ioctl(0, TIOCSETD, (char *)&odisc); |
unraw(); |
unraw(); |
|
if (signo && tipout_pid) { |
|
kill(tipout_pid, signo); |
|
wait(NULL); |
|
} |
exit(0); |
exit(0); |
} |
} |
|
|