From 87c3fdfe678cfbfd06c0343a4c36a1480d23a6ee Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 30 Jun 2011 03:57:49 +0000 Subject: [PATCH] add signal handlers SVN revision: 60857 --- legacy/eeze/src/bin/eeze_scanner.c | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/legacy/eeze/src/bin/eeze_scanner.c b/legacy/eeze/src/bin/eeze_scanner.c index de18edb..f3f7e6e 100644 --- a/legacy/eeze/src/bin/eeze_scanner.c +++ b/legacy/eeze/src/bin/eeze_scanner.c @@ -379,6 +379,42 @@ cb_stor_chg(const char *device, Eeze_Udev_Event ev, void *data __UNUSED__, Eeze_ } } +static void +es_exit(int sig) +{ + const char *tmp; + char buf[1024]; + struct stat st; + ecore_con_server_del(svr); + + tmp = getenv("TMPDIR"); + if (!tmp) tmp = "/tmp"; + + snprintf(buf, sizeof(buf), "%s/.ecore_service|eeze_scanner|0", tmp); + if (!stat(buf, &st)) + unlink(buf); + exit(sig); +} + +static void +sigs_setup(void *d __UNUSED__) +{ + sigset_t sigs = {{0}}; + struct sigaction s; + + sigfillset(&sigs); + sigdelset(&sigs, SIGSEGV); + sigdelset(&sigs, SIGTERM); + sigdelset(&sigs, SIGINT); + sigdelset(&sigs, SIGQUIT); + + s.sa_handler = es_exit; + s.sa_flags = 0; + sigaction(SIGTERM, &s, NULL); + sigaction(SIGSEGV, &s, NULL); + sigaction(SIGINT, &s, NULL); +} + int main(void) { @@ -430,7 +466,11 @@ main(void) } storage_setup(); + /* have to override ecore's signal handlers to ensure that socket file is removed */ + ecore_job_add(sigs_setup, NULL); ecore_main_loop_begin(); + + ecore_con_server_del(svr); return 0; error: ERR("Could not start up!"); -- 2.7.4