Change in osmo-remsim[master]: remsim-client: Avoid zombies when scripts terminate

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/.

laforge gerrit-no-reply at lists.osmocom.org
Tue Oct 20 17:24:42 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-remsim/+/20808 )

Change subject: remsim-client: Avoid zombies when scripts terminate
......................................................................

remsim-client: Avoid zombies when scripts terminate

This avoids the OS from keeping terminated children (scripts) around
as zombies.

Change-Id: If7d45bda160987a26c7b101db6152142dc432fe7
---
M src/client/remsim_client_main.c
1 file changed, 20 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/src/client/remsim_client_main.c b/src/client/remsim_client_main.c
index bc916b9..bbc2990 100644
--- a/src/client/remsim_client_main.c
+++ b/src/client/remsim_client_main.c
@@ -1,4 +1,5 @@
 
+#include <errno.h>
 #include <signal.h>
 #include <unistd.h>
 #define _GNU_SOURCE
@@ -142,6 +143,19 @@
 	}
 }
 
+
+static int avoid_zombies(void)
+{
+	static struct sigaction sa_chld;
+
+	sa_chld.sa_handler = SIG_IGN;
+	sigemptyset(&sa_chld.sa_mask);
+	sa_chld.sa_flags = SA_NOCLDWAIT;
+	sa_chld.sa_restorer = NULL;
+
+	return sigaction(SIGCHLD, &sa_chld, NULL);
+}
+
 int main(int argc, char **argv)
 {
 	struct bankd_client *g_client;
@@ -166,6 +180,12 @@
 
 	signal(SIGUSR1, handle_sig_usr1);
 
+	/* Silently (and portably) reap children. */
+	if (avoid_zombies() < 0) {
+		fprintf(stderr, "Unable to silently reap children: %s\n", strerror(errno));
+		exit(1);
+	}
+
 	asn_debug = 0;
 
 	client_user_main(g_client);

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/20808
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: If7d45bda160987a26c7b101db6152142dc432fe7
Gerrit-Change-Number: 20808
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201020/88732aaf/attachment.htm>


More information about the gerrit-log mailing list