GNU/Linux: Application can exit by SIGINT or SIGTERM.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka
2021-02-10 09:33:53 +09:00
parent bd66c51e35
commit c1433f1520
2 changed files with 9 additions and 2 deletions

View File

@@ -4,6 +4,7 @@
* chopstx-gnu-linux.c (chopstx_create_arch): Fix ARGC of
makecontext call.
(chx_idle): Support exit by SIGINT or SIGTERM.
2021-02-09 NIIBE Yutaka <gniibe@fsij.org>

View File

@@ -174,7 +174,13 @@ chx_idle (void)
if (sig == SIGALRM)
tp_next = chx_timer_expired ();
else
tp_next = chx_recv_irq (sig);
{
tp_next = chx_recv_irq (sig);
/* Exit when there is no waiter and it's INT or TERM. */
if (tp_next == NULL
&& (sig == SIGINT || sig == SIGTERM))
exit (1);
}
}
return tp_next;
@@ -280,7 +286,7 @@ voluntary_context_switch (struct chx_thread *tp_next)
tp_next = chx_idle ();
chx_set_running (tp_next);
if (tp_prev != tp_next)
swapcontext (&tp_prev->tc, &tp_next->tc);
swapcontext (&tp_prev->tc, &tp_next->tc);
}
else
{