"Options:\n"
" -l <port> port to listen to\n"
" -p <pidfile> file to write our pid to\n"
+ " -f stay in foreground\n"
, stderr);
}
.sin_addr = { htonl(INADDR_LOOPBACK) },
};
const char *pidfile = NULL;
+ bool daemonize = true;
int port = DEFAULT_PORT;
int sock = -1;
- for (int c = 0; (c = getopt(argc, argv, "h" "l:p:")) >= 0; ) {
+ for (int c = 0; (c = getopt(argc, argv, "hf" "l:p:")) >= 0; ) {
switch (c) {
case 'p':
pidfile = optarg;
case 'l':
port = atoi(optarg);
break;
+ case 'f':
+ daemonize = false;
+ break;
default:
usage();
return EXIT_FAILURE;
return EXIT_FAILURE;
}
- if (daemon_detach() < 0) {
+ if (daemonize && daemon_detach() < 0) {
syslog(LOG_CRIT, "unable to fork");
return EXIT_FAILURE;
}
" (default: "STR(DEFAULT_DECODER_PORT)")\n"
" -p <pidfile> file to write our pid to\n"
" -u unsafe mode: don't drop privilegies\n"
+ " -f stay in foreground\n"
, stderr);
}
int main(int argc, char *argv[])
{
bool unsafe = false;
+ bool daemonize = true;
int port_enc = DEFAULT_ENCODER_PORT;
int port_dec = DEFAULT_DECODER_PORT;
const char *pidfile = NULL;
int res;
srs_t *srs;
- for (int c = 0; (c = getopt(argc, argv, "hu" "e:d:p:")) >= 0; ) {
+ for (int c = 0; (c = getopt(argc, argv, "hfu" "e:d:p:")) >= 0; ) {
switch (c) {
case 'e':
port_enc = atoi(optarg);
break;
+ case 'f':
+ daemonize = false;
+ break;
case 'd':
port_dec = atoi(optarg);
break;
return EXIT_FAILURE;
}
- if (daemon_detach() < 0) {
+ if (daemonize && daemon_detach() < 0) {
syslog(LOG_CRIT, "unable to fork");
return EXIT_FAILURE;
}