diff options
author | Konstantin Belousov <kib@FreeBSD.org> | 2009-10-11 17:04:13 +0000 |
---|---|---|
committer | Konstantin Belousov <kib@FreeBSD.org> | 2009-10-11 17:04:13 +0000 |
commit | eb9de28f2018d17997a4d83d3a303bb7e4c10f4c (patch) | |
tree | 9133512380c3597aa80565bcd9399c58f2b32ce1 /tools/regression | |
parent | 6b286ee8b5fe6b8fec7fb78f030b151a7767886c (diff) | |
download | src-eb9de28f2018d17997a4d83d3a303bb7e4c10f4c.tar.gz src-eb9de28f2018d17997a4d83d3a303bb7e4c10f4c.zip |
Tweaks for sigqueue tests:
- slightly adjust code for style, sort headers.
- in sigqtest2, print received signals, to make it easy to see why test
failed.
- in sigqtest2, job_control_test(), cover a race by adding sleep after
child stopped itself to allow for SIGCHLD due to stop and exit to not
be coalesced.
MFC after: 2 weeks
Notes
Notes:
svn path=/head/; revision=197965
Diffstat (limited to 'tools/regression')
-rw-r--r-- | tools/regression/sigqueue/sigqtest1/sigqtest1.c | 11 | ||||
-rw-r--r-- | tools/regression/sigqueue/sigqtest2/sigqtest2.c | 28 |
2 files changed, 27 insertions, 12 deletions
diff --git a/tools/regression/sigqueue/sigqtest1/sigqtest1.c b/tools/regression/sigqueue/sigqtest1/sigqtest1.c index 0f40021b4ab6..f0201c37af86 100644 --- a/tools/regression/sigqueue/sigqtest1/sigqtest1.c +++ b/tools/regression/sigqueue/sigqtest1/sigqtest1.c @@ -1,12 +1,14 @@ /* $FreeBSD$ */ -#include <signal.h> -#include <stdio.h> #include <err.h> #include <errno.h> +#include <signal.h> +#include <stdio.h> +#include <unistd.h> int received; -void handler(int sig, siginfo_t *si, void *ctx) +void +handler(int sig, siginfo_t *si, void *ctx) { if (si->si_code != SI_QUEUE) errx(1, "si_code != SI_QUEUE"); @@ -15,7 +17,8 @@ void handler(int sig, siginfo_t *si, void *ctx) received++; } -int main() +int +main() { struct sigaction sa; union sigval val; diff --git a/tools/regression/sigqueue/sigqtest2/sigqtest2.c b/tools/regression/sigqueue/sigqtest2/sigqtest2.c index 078ea81f6278..50b579d0a42c 100644 --- a/tools/regression/sigqueue/sigqtest2/sigqtest2.c +++ b/tools/regression/sigqueue/sigqtest2/sigqtest2.c @@ -1,24 +1,29 @@ /* $FreeBSD$ */ -#include <signal.h> -#include <stdio.h> -#include <err.h> -#include <errno.h> #include <sys/types.h> #include <sys/wait.h> +#include <err.h> +#include <errno.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> int stop_received; int exit_received; int cont_received; -void job_handler(int sig, siginfo_t *si, void *ctx) +void +job_handler(int sig, siginfo_t *si, void *ctx) { int status; int ret; if (si->si_code == CLD_STOPPED) { + printf("%d: stop received\n", si->si_pid); stop_received = 1; kill(si->si_pid, SIGCONT); } else if (si->si_code == CLD_EXITED) { + printf("%d: exit received\n", si->si_pid); ret = waitpid(si->si_pid, &status, 0); if (ret == -1) errx(1, "waitpid"); @@ -26,11 +31,13 @@ void job_handler(int sig, siginfo_t *si, void *ctx) errx(1, "!WIFEXITED(status)"); exit_received = 1; } else if (si->si_code == CLD_CONTINUED) { + printf("%d: cont received\n", si->si_pid); cont_received = 1; } } -void job_control_test() +void +job_control_test(void) { struct sigaction sa; pid_t pid; @@ -43,9 +50,12 @@ void job_control_test() stop_received = 0; cont_received = 0; exit_received = 0; + fflush(stdout); pid = fork(); if (pid == 0) { + printf("child %d\n", getpid()); kill(getpid(), SIGSTOP); + sleep(2); exit(1); } @@ -60,11 +70,13 @@ void job_control_test() printf("job control test OK.\n"); } -void rtsig_handler(int sig, siginfo_t *si, void *ctx) +void +rtsig_handler(int sig, siginfo_t *si, void *ctx) { } -int main() +int +main() { struct sigaction sa; sigset_t set; |