summaryrefslogtreecommitdiff
path: root/src/c
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-11-20 12:16:30 -0500
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-11-20 12:16:30 -0500
commit0363434b9bbdea2e3ab9c432036941c0557ab62c (patch)
tree2a5822346670938e7d1be8b131e9a0b7d3959408 /src/c
parenta01f4dd530689d29ac7518bb9a8d19b919ef76ac (diff)
Profiling support
Diffstat (limited to 'src/c')
-rw-r--r--src/c/driver.c11
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 '?':