signal fluff for qujitting

This commit is contained in:
Bjorn Andersson 2006-06-05 14:46:10 +00:00
parent 5c61baa2be
commit e1c0a595df

View file

@ -17,6 +17,7 @@
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <signal.h>
#include <err.h>
#include "tun.h"
@ -24,6 +25,13 @@
#define MAX(a,b) ((a)>(b)?(a):(b))
int running = 1;
static void
sigint(int sig) {
running = 0;
}
static int
tunnel(int tun_fd, int dns_fd)
{
@ -31,7 +39,7 @@ tunnel(int tun_fd, int dns_fd)
fd_set fds;
struct timeval tv;
for (;;) {
while (running) {
tv.tv_sec = 1;
tv.tv_usec = 0;
@ -69,11 +77,16 @@ main()
tun_fd = open_tun();
dns_fd = open_dns();
signal(SIGINT, sigint);
dns_set_peer("192.168.11.101");
dns_query(dns_fd, "kryo.se", 1);
tunnel(tun_fd, dns_fd);
printf("Closing tunnel\n");
close_dns(dns_fd);
close_tun(tun_fd);