All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] main: Add handler for SIGSEGV signal
@ 2021-01-25 22:31 Inga Stotland
  2021-01-26  0:35 ` Denis Kenzior
  2021-01-26  9:02 ` Marcel Holtmann
  0 siblings, 2 replies; 5+ messages in thread
From: Inga Stotland @ 2021-01-25 22:31 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 1475 bytes --]

When an ell main loop based process is spun off as a child
and the parent process dies due to a segfault, the child process
is still left running and needs to detect the segfault condition.
To address this need, add watch and signal handler for SIGSEGV.
---
 ell/main.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/ell/main.c b/ell/main.c
index a479b74..712cfb7 100644
--- a/ell/main.c
+++ b/ell/main.c
@@ -619,6 +619,14 @@ static void sigterm_handler(void *user_data)
 		data->callback(SIGTERM, data->user_data);
 }
 
+static void sigsegv_handler(void *user_data)
+{
+	struct signal_data *data = user_data;
+
+	if (data->callback)
+		data->callback(SIGSEGV, data->user_data);
+}
+
 /**
  * l_main_run_with_signal:
  *
@@ -633,6 +641,7 @@ LIB_EXPORT int l_main_run_with_signal(l_main_signal_cb_t callback,
 	struct signal_data *data;
 	struct l_signal *sigint;
 	struct l_signal *sigterm;
+	struct l_signal *sigsegv;
 	int result;
 
 	data = l_new(struct signal_data, 1);
@@ -642,11 +651,13 @@ LIB_EXPORT int l_main_run_with_signal(l_main_signal_cb_t callback,
 
 	sigint = l_signal_create(SIGINT, sigint_handler, data, NULL);
 	sigterm = l_signal_create(SIGTERM, sigterm_handler, data, NULL);
+	sigsegv = l_signal_create(SIGSEGV, sigsegv_handler, data, NULL);
 
 	result = l_main_run();
 
 	l_signal_remove(sigint);
 	l_signal_remove(sigterm);
+	l_signal_remove(sigsegv);
 
 	l_free(data);
 
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-01-27 17:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-25 22:31 [PATCH] main: Add handler for SIGSEGV signal Inga Stotland
2021-01-26  0:35 ` Denis Kenzior
2021-01-26  9:02 ` Marcel Holtmann
2021-01-26 23:46   ` Stotland, Inga
2021-01-27 17:53   ` Stotland, Inga

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.