+ signal(SIGHUP, hup);
+ signal(SIGINT, hup);
+ signal(SIGUSR1, do_nothing); // Used in internal signalling.
+ signal(SIGPIPE, SIG_IGN);
+
+ // Parse options.
+ int state_fd = -1;
+ bool test_config = false;
+ for ( ;; ) {
+ static const option long_options[] = {
+ { "state", required_argument, 0, 's' },
+ { "test-config", no_argument, 0, 't' },
+ { 0, 0, 0, 0 }
+ };
+ int option_index = 0;
+ int c = getopt_long(argc, argv, "s:t", long_options, &option_index);
+
+ if (c == -1) {
+ break;
+ }
+ switch (c) {
+ case 's':
+ state_fd = atoi(optarg);
+ break;
+ case 't':
+ test_config = true;
+ break;
+ default:
+ fprintf(stderr, "Unknown option '%s'\n", argv[option_index]);
+ exit(1);
+ }
+ }