4 # Copyright (c) 2013 EMC Corp.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 # Regression test for kern/142757, race condition in traced process signal
30 # handling. Fixed in r202692.
32 # Test scenario by Tijl Coosemans, tijl@
39 #include <sys/types.h>
40 #include <sys/ptrace.h>
53 /* fork dummy child process */
56 /* child does nothing */
63 for (i = 0; i < 100000; i++) {
64 /* loop: attach, wait, detach */
67 ptrace(PT_ATTACH, pid, (caddr_t) 0, 0);
71 wait4(pid, &status, 0, NULL);
75 ptrace(PT_DETACH, pid, (caddr_t) 1, 0);
88 #include <sys/types.h>
89 #include <sys/ptrace.h>
102 /* fork dummy child process */
105 /* child does nothing */
112 ptrace(PT_ATTACH, pid, (caddr_t) 0, 0);
113 wait4(pid, &status, 0, NULL);
114 for (i = 0; i < 100000; i++) {
115 /* loop: continue, kill, wait */
118 ptrace(PT_CONTINUE, pid, (caddr_t) 1, 0);
126 wait4(pid, &status, 0, NULL);
137 mycc -o race1 -Wall -Wextra race1.c
138 mycc -o race2 -Wall -Wextra race2.c
140 ./race1 > /dev/null || echo "FAIL #1"
141 ./race2 > /dev/null || echo "FAIL #2"
143 rm -f race1.c race1 race2.c race2