diff options
-rw-r--r-- | regress/sys/kern/signal/Makefile | 4 | ||||
-rw-r--r-- | regress/sys/kern/signal/earlysig/Makefile | 5 | ||||
-rw-r--r-- | regress/sys/kern/signal/earlysig/earlysig.c | 49 |
3 files changed, 56 insertions, 2 deletions
diff --git a/regress/sys/kern/signal/Makefile b/regress/sys/kern/signal/Makefile index 234b1e3a15d..46de87097ae 100644 --- a/regress/sys/kern/signal/Makefile +++ b/regress/sys/kern/signal/Makefile @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile,v 1.2 2005/07/13 14:53:54 otto Exp $ +# $OpenBSD: Makefile,v 1.3 2005/08/08 18:53:35 otto Exp $ -SUBDIR+= sigfpe siginfo_addr fpsig +SUBDIR+= sigfpe siginfo_addr fpsig earlysig install: diff --git a/regress/sys/kern/signal/earlysig/Makefile b/regress/sys/kern/signal/earlysig/Makefile new file mode 100644 index 00000000000..e9396582b8d --- /dev/null +++ b/regress/sys/kern/signal/earlysig/Makefile @@ -0,0 +1,5 @@ +# $OpenBSD: Makefile,v 1.1 2005/08/08 18:53:36 otto Exp $ + +PROG=earlysig + +.include <bsd.regress.mk> diff --git a/regress/sys/kern/signal/earlysig/earlysig.c b/regress/sys/kern/signal/earlysig/earlysig.c new file mode 100644 index 00000000000..db0d0eb9880 --- /dev/null +++ b/regress/sys/kern/signal/earlysig/earlysig.c @@ -0,0 +1,49 @@ +/* $OpenBSD: earlysig.c,v 1.1 2005/08/08 18:53:36 otto Exp $ */ + +/* + * Public domain. 2005, Otto Moerbeek + * + * Try to create the case where a signal is deliverd to a proces before + * fork() returns. + */ + +#include <sys/types.h> +#include <sys/wait.h> + +#include <err.h> +#include <stdio.h> +#include <stdlib.h> +#include <signal.h> +#include <unistd.h> + +void dohup(int signo) +{ +} + +int +main() +{ + pid_t pid; + int status; + + signal(SIGHUP, dohup); + + switch(pid = fork()) { + case -1: + err(1, "fork"); + break; + case 0: + sleep(2); + exit(0); + default: + kill(pid, SIGHUP); + sleep(1); + if (waitpid(pid, &status, 0) == -1) + err(1, "waitpid"); + if (WIFEXITED(status) && WEXITSTATUS(status) == 0) + exit(0); + else + errx(1, "child exited with status %d", + WEXITSTATUS(status)); + } +} |