From 5d2c8a24f2dec4f5edf4c5f4b3c3f35ca9561fd6 Mon Sep 17 00:00:00 2001 From: Nathan Straz Date: Thu, 15 Aug 2013 14:13:51 -0400 Subject: Add option to pause at startup This allows us to attach gdb before anything interesting happens. Use the command 'signal 14' to get the process running again. --- qarshd.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'qarshd.c') diff --git a/qarshd.c b/qarshd.c index 950135e..91e2501 100644 --- a/qarshd.c +++ b/qarshd.c @@ -46,6 +46,7 @@ */ int debug = 0; +int dopause = 0; /* Globals */ struct sockaddr_storage peername; @@ -279,10 +280,11 @@ handle_packets(int infd) sa.sa_mask = sigmask; sa.sa_flags = SA_RESTART; sigaction(SIGCHLD, &sa, NULL); -#if 0 - signal(SIGALRM, sig_handler); - pause(); -#endif + if (dopause) { + signal(SIGALRM, sig_handler); + pause(); + signal(SIGALRM, SIG_DFL); + } for (;;) { FD_SET(infd, &rfds); @@ -397,11 +399,14 @@ main(int argc, char *argv[]) openlog("qarshd", LOG_PID, LOG_DAEMON); - while ((ch = getopt(argc, argv, "d")) != -1) { + while ((ch = getopt(argc, argv, "pd")) != -1) { switch (ch) { case 'd': debug = 1; break; + case 'p': + dopause = 1; + break; case '?': default: printf("unknown option '%c'\n", optopt); -- cgit