diff options
author | Matt Strapp <strap012@umn.edu> | 2020-11-15 12:40:03 -0600 |
---|---|---|
committer | Matt Strapp <strap012@umn.edu> | 2020-11-15 12:40:03 -0600 |
commit | f7ef85a44deb268b849e4810fdcdaa241b6eb7a1 (patch) | |
tree | dd5a97d5e4fbcab2f54ac7caa7f5c602ef1256a1 | |
parent | Add VScode stuffs (diff) | |
download | csci4061-f7ef85a44deb268b849e4810fdcdaa241b6eb7a1.tar csci4061-f7ef85a44deb268b849e4810fdcdaa241b6eb7a1.tar.gz csci4061-f7ef85a44deb268b849e4810fdcdaa241b6eb7a1.tar.bz2 csci4061-f7ef85a44deb268b849e4810fdcdaa241b6eb7a1.tar.lz csci4061-f7ef85a44deb268b849e4810fdcdaa241b6eb7a1.tar.xz csci4061-f7ef85a44deb268b849e4810fdcdaa241b6eb7a1.tar.zst csci4061-f7ef85a44deb268b849e4810fdcdaa241b6eb7a1.zip |
Add loop
-rw-r--r-- | P3/server.c | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/P3/server.c b/P3/server.c index 87b8339..a42c578 100644 --- a/P3/server.c +++ b/P3/server.c @@ -124,6 +124,7 @@ void * worker(void *arg) { /**********************************************************************************/ +static volatile sig_atomic_t exitFlag = 0; int main(int argc, char **argv) { // Error check on number of arguments @@ -161,10 +162,16 @@ int main(int argc, char **argv) { struct sigaction act; sigset_t sigset; act.sa_handler = eggs; + act.sa_flags = 0; + if (sigemptyset(&act.sa_mask) == -1 || + sigaction(SIGINT, &act, NULL) == -1) { + perror("SIGINT handler failed.\n"); + return -1; + } // Open log file - + FILE* logfile = fopen("serverlog.txt", "a+"); // Change the current working directory to server root directory - + chdir("testing/"); // Initialize cache (extra credit B) // Start the server @@ -175,12 +182,25 @@ int main(int argc, char **argv) { // Create dynamic pool manager thread (extra credit A) - return 0; + //Server loop (RUNS FOREVER) + while (1) { + //TODO: Add something else? + + // Terminate server gracefully + if (exitFlag){ + // Print the number of pending requests in the request queue + // close log file + fclose(logfile); + // Remove cache (extra credit B) + + return 0; + } + + } + printf("This should never be printed."); + return 42; } static void eggs(int signo) { - // Terminate server gracefully - // Print the number of pending requests in the request queue - // close log file - // Remove cache (extra credit B) + exitFlag |= 1; } |