summaryrefslogtreecommitdiff
path: root/src/bin/evas/evas_cserve2_main_loop_linux.c
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2013-06-12 19:31:37 +0900
committerCedric Bail <cedric.bail@samsung.com>2013-06-14 16:38:18 +0900
commita3b3b5bd8e8a41501e8e22514dd0d381580a8f21 (patch)
treee5fb938044e60b061fa357d6f3b6674ed08d5d5a /src/bin/evas/evas_cserve2_main_loop_linux.c
parent338218109bf4c889d5392fb8a810b189eb661ca1 (diff)
evas/cserve2: Handle SIGINT properly
Diffstat (limited to 'src/bin/evas/evas_cserve2_main_loop_linux.c')
-rw-r--r--src/bin/evas/evas_cserve2_main_loop_linux.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/bin/evas/evas_cserve2_main_loop_linux.c b/src/bin/evas/evas_cserve2_main_loop_linux.c
index 590a8625f2..c29f9425de 100644
--- a/src/bin/evas/evas_cserve2_main_loop_linux.c
+++ b/src/bin/evas/evas_cserve2_main_loop_linux.c
@@ -143,14 +143,22 @@ _signalfd_handler(int fd, Fd_Flags flags EINA_UNUSED, void *data EINA_UNUSED)
143 } 143 }
144} 144}
145 145
146static void
147_sigint_handler(int id, siginfo_t *info EINA_UNUSED, void *data EINA_UNUSED)
148{
149 if (id != SIGINT) return;
150 DBG("Received SIGINT. Honoring request.");
151 terminate = EINA_TRUE;
152}
153
146static int 154static int
147_signalfd_setup(void) 155_signalfd_setup(void)
148{ 156{
149 sigset_t mask; 157 sigset_t mask;
158 struct sigaction action;
150 159
151 sigemptyset(&mask); 160 sigemptyset(&mask);
152 sigaddset(&mask, SIGCHLD); 161 sigaddset(&mask, SIGCHLD);
153 sigaddset(&mask, SIGINT);
154 sigaddset(&mask, SIGTERM); 162 sigaddset(&mask, SIGTERM);
155 sigaddset(&mask, SIGQUIT); 163 sigaddset(&mask, SIGQUIT);
156 sigaddset(&mask, SIGUSR1); 164 sigaddset(&mask, SIGUSR1);
@@ -169,6 +177,11 @@ _signalfd_setup(void)
169 /* ignore SIGPIPE so it's handled by write() and send() as needed */ 177 /* ignore SIGPIPE so it's handled by write() and send() as needed */
170 signal(SIGPIPE, SIG_IGN); 178 signal(SIGPIPE, SIG_IGN);
171 179
180 action.sa_sigaction = _sigint_handler;
181 action.sa_flags = SA_SIGINFO;
182 sigemptyset(&action.sa_mask);
183 sigaction(SIGINT, &action, NULL);
184
172 return signal_fd; 185 return signal_fd;
173} 186}
174 187
@@ -768,9 +781,16 @@ cserve2_main_loop_run(void)
768 nfds = epoll_wait(epoll_fd, events, MAX_EPOLL_EVENTS, timeout); 781 nfds = epoll_wait(epoll_fd, events, MAX_EPOLL_EVENTS, timeout);
769 if (nfds < 0) 782 if (nfds < 0)
770 { 783 {
771 ERR("An error occurred when reading the epoll fd."); 784 if (errno == EINTR && !terminate)
772 ERR("%s", strerror(errno)); 785 {
773 break; 786 INF("Ignoring interruption during epoll_wait.");
787 continue;
788 }
789 else
790 {
791 ERR("An error occurred when reading the epoll fd: %s.", strerror(errno));
792 break;
793 }
774 } 794 }
775 if (nfds == 0) // timeout occurred 795 if (nfds == 0) // timeout occurred
776 { 796 {