newlib/winsup/testsuite/winsup.api/signal-into-win32-api.c
Christopher Faylor 9b978ffe8b * libltp/include/test.h: Fix C warnings.
* winsup.api/checksignal.c: Ditto.
* winsup.api/crlf.c: Ditto.
* winsup.api/devzero.c: Ditto.
* winsup.api/iospeed.c: Ditto.
* winsup.api/mmaptest01.c: Ditto.
* winsup.api/mmaptest02.c: Ditto.
* winsup.api/mmaptest03.c: Ditto.
* winsup.api/mmaptest04.c: Ditto.
* winsup.api/nullgetcwd.c: Ditto.
* winsup.api/sigchld.c: Ditto.
* winsup.api/signal-into-win32-api.c: Ditto.
* winsup.api/systemcall.c: Ditto.
* winsup.api/waitpid.c: Ditto.
* winsup.api/pthread/mainthreadexits.c: Ditto.
* winsup.api/pthread/test.h: Ditto.
* winsup.api/pthread/threadidafterfork.c: Ditto.
* Makefile.in: Remove cygrun.exe from RUNTIME since it is built here now.
2003-01-23 21:21:28 +00:00

59 lines
943 B
C
Executable File

/*
* 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;
}
exit (0);
}