From 229bf123cec9c628478214552487b29f541177d3 Mon Sep 17 00:00:00 2001 From: fadhil riyanto Date: Sat, 28 Sep 2024 20:48:54 +0700 Subject: test mmap() Signed-off-by: fadhil riyanto --- test/signalbychild.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/signalbychild.c b/test/signalbychild.c index 462daf4..6866f06 100644 --- a/test/signalbychild.c +++ b/test/signalbychild.c @@ -4,8 +4,9 @@ #include #include #include +#include -int volatile g_signal_need_exit = 0; +int *g_signal_need_exit; int saved_ppid = 0; void signal_notify(int signum) @@ -15,7 +16,7 @@ void signal_notify(int signum) printf("parent got signal %d\n", signum); } - g_signal_need_exit = 1; + *g_signal_need_exit = 1; } @@ -44,6 +45,10 @@ static void enter_eventloop(void) int main(void) { + g_signal_need_exit = mmap(NULL, sizeof(int), PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_SHARED, -1, 0); + *g_signal_need_exit = 0; + + saved_ppid = getpid(); install_signal(); @@ -57,4 +62,6 @@ int main(void) } while(wait(NULL) > 0); + + munmap(g_signal_need_exit, sizeof(int)); } \ No newline at end of file -- cgit v1.2.3