Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/testsuite/winsup.api/signal-into-win32-api.c')
-rwxr-xr-xwinsup/testsuite/winsup.api/signal-into-win32-api.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/winsup/testsuite/winsup.api/signal-into-win32-api.c b/winsup/testsuite/winsup.api/signal-into-win32-api.c
new file mode 100755
index 000000000..0c299827a
--- /dev/null
+++ b/winsup/testsuite/winsup.api/signal-into-win32-api.c
@@ -0,0 +1,57 @@
+/*
+ * Test if signal is delivered to the application which is
+ * currently inside of native syscall
+ */
+
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <windows.h>
+
+int saw_sigchld = 0;
+int sleep_stage = -1;
+
+void
+handle_child (int signo)
+{
+ printf ( "saw SIGCHLD, %d", sleep_stage);
+ saw_sigchld = 1;
+}
+
+int
+main (int argc, char** argv)
+{
+ pid_t pid;
+ if (argc > 1)
+ {
+ Sleep (200);
+ return 0;
+ }
+
+ signal (SIGCHLD, handle_child);
+ pid = fork ();
+ if (pid < 0)
+ {
+ perror ( "fork" );
+ return 2;
+ }
+ else if (pid == 0)
+ execl ( argv[0], argv[0], "child", 0 );
+ else
+ {
+ sleep_stage = 0;
+ Sleep (3000);
+ sleep_stage = 1;
+ sleep (10);
+ sleep_stage = 2;
+ if (!saw_sigchld)
+ {
+ printf ( "oops\n" );
+ kill (pid, SIGTERM);
+ return 1;
+ }
+ else
+ return 0;
+ }
+} \ No newline at end of file