diff options
author | Adam Chlipala <adamc@hcoop.net> | 2008-11-20 12:16:30 -0500 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2008-11-20 12:16:30 -0500 |
commit | 0363434b9bbdea2e3ab9c432036941c0557ab62c (patch) | |
tree | 2a5822346670938e7d1be8b131e9a0b7d3959408 /src/c | |
parent | a01f4dd530689d29ac7518bb9a8d19b919ef76ac (diff) |
Profiling support
Diffstat (limited to 'src/c')
-rw-r--r-- | src/c/driver.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/c/driver.c b/src/c/driver.c index f80361b1..ce0d194e 100644 --- a/src/c/driver.c +++ b/src/c/driver.c @@ -1,10 +1,12 @@ #include <stdio.h> #include <string.h> +#include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <unistd.h> +#include <signal.h> #include <pthread.h> @@ -297,6 +299,11 @@ static void help(char *cmd) { printf("Usage: %s [-p <port>] [-t <thread-count>]\n", cmd); } +static void sigint(int signum) { + printf("Exiting....\n"); + exit(0); +} + int main(int argc, char *argv[]) { // The skeleton for this function comes from Beej's sockets tutorial. int sockfd; // listen on sock_fd @@ -304,7 +311,9 @@ int main(int argc, char *argv[]) { struct sockaddr_in their_addr; // connector's address information int sin_size, yes = 1; int uw_port = 8080, nthreads = 1, i, *names, opt; - + + signal(SIGINT, sigint); + while ((opt = getopt(argc, argv, "hp:t:")) != -1) { switch (opt) { case '?': |