summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Straz <nstraz@redhat.com>2013-08-15 14:13:51 -0400
committerNathan Straz <nstraz@redhat.com>2013-09-11 17:49:23 -0400
commit5d2c8a24f2dec4f5edf4c5f4b3c3f35ca9561fd6 (patch)
tree63322897c8ed682a48a0975cfa47943a6c159d44
parent0fbaf9ea5bdd6b7a347d09dc4bb135cc777c7543 (diff)
downloadqarsh-5d2c8a24f2dec4f5edf4c5f4b3c3f35ca9561fd6.tar.gz
qarsh-5d2c8a24f2dec4f5edf4c5f4b3c3f35ca9561fd6.tar.xz
qarsh-5d2c8a24f2dec4f5edf4c5f4b3c3f35ca9561fd6.zip
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.
-rw-r--r--qarshd.c15
1 files changed, 10 insertions, 5 deletions
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);