Change in osmo-sip-connector[master]: Added daemonize feature to osmo-sip-connector

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Rafael Diniz gerrit-no-reply at lists.osmocom.org
Thu Apr 18 23:31:45 UTC 2019


Rafael Diniz has uploaded this change for review. ( 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(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-sip-connector refs/changes/04/13704/1

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: newchange
Gerrit-Change-Id: I400fb5a2619f348cc60e8c9016154afa60424e66
Gerrit-Change-Number: 13704
Gerrit-PatchSet: 1
Gerrit-Owner: Rafael Diniz <rafael at rhizomatica.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190418/1f8cd173/attachment.htm>


More information about the gerrit-log mailing list