summaryrefslogtreecommitdiff
path: root/test/signalbychild.c
diff options
context:
space:
mode:
authorfadhil riyanto <me@fadev.org>2024-09-28 20:48:54 +0700
committerfadhil riyanto <me@fadev.org>2024-09-28 20:48:54 +0700
commit229bf123cec9c628478214552487b29f541177d3 (patch)
treea5f83b32785891a99b4ec4805623ce8f3bf4d379 /test/signalbychild.c
parentbb83998c2232c93bfa8cf04c030e21f94a125baf (diff)
test mmap()
Signed-off-by: fadhil riyanto <me@fadev.org>
Diffstat (limited to 'test/signalbychild.c')
-rw-r--r--test/signalbychild.c11
1 files 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 <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
+#include <sys/mman.h>
-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