Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13704 )

Change subject: Added daemonize feature to osmo-sip-connector
......................................................................

Added daemonize feature to osmo-sip-connector

Change-Id: I400fb5a2619f348cc60e8c9016154afa60424e66
---
M src/main.c
1 file changed, 16 insertions(+), 2 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Rafael Diniz: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved



diff --git a/src/main.c b/src/main.c
index 0661498..ab58a52 100644
--- a/src/main.c
+++ b/src/main.c
@@ -46,6 +46,7 @@

 void *tall_mncc_ctx;

+static bool daemonize = false;
 static char *config_file = "osmo-sip-connector.cfg";

 static struct log_info_cat mncc_sip_categories[] = {
@@ -79,8 +80,9 @@
 static void print_help(void)
 {
        printf("OsmoSIPcon: MNCC to SIP bridge\n");
-       printf("  -h --help\tthis text\n");
+       printf("  -h --help\tThis text\n");
        printf("  -c --config-file NAME\tThe config file to use [%s]\n", 
config_file);
+       printf("  -D --daemonize\tFork the process into a background daemon\n");
        printf("  -V --version\tPrint the version number\n");
 }

@@ -91,11 +93,12 @@
                static struct option long_options[] = {
                        {"help", 0, 0, 'h'},
                        {"config-file", 1, 0, 'c'},
+                       {"daemonize", 0, 0, 'D'},
                        {"version", 0, 0, 'V' },
                        {NULL, 0, 0, 0}
                };

-               c = getopt_long(argc, argv, "hc:V",
+               c = getopt_long(argc, argv, "hc:DV",
                        long_options, &option_index);
                if (c == -1)
                        break;
@@ -107,6 +110,9 @@
                case 'c':
                        config_file = optarg;
                        break;
+               case 'D':
+                       daemonize = true;
+                       break;
                case 'V':
                        print_version(1);
                        exit(EXIT_SUCCESS);
@@ -159,6 +165,14 @@
        calls_init();
        app_setup(&g_app);

+       if (daemonize) {
+               rc = osmo_daemonize();
+               if (rc < 0) {
+                       perror("Error during daemonize");
+                       exit(1);
+               }
+       }
+
        /* marry sofia-sip to glib and glib to libosmocore */
        loop = g_main_loop_new(NULL, FALSE);
        g_source_attach(su_glib_root_gsource(g_app.sip.agent.root),

--
To view, visit https://gerrit.osmocom.org/13704
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sip-connector
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I400fb5a2619f348cc60e8c9016154afa60424e66
Gerrit-Change-Number: 13704
Gerrit-PatchSet: 1
Gerrit-Owner: Rafael Diniz <[email protected]>
Gerrit-Reviewer: Harald Welte <[email protected]>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Rafael Diniz <[email protected]>

Reply via email to