plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Copyright (c) International Business Machines Corp., 2001 |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
| 13 | * the GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
Wanlong Gao | 4548c6c | 2012-10-19 18:03:36 +0800 | [diff] [blame] | 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 18 | */ |
| 19 | |
| 20 | /* |
| 21 | * NAME |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 22 | * fcntl17.c |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 23 | * |
| 24 | * DESCRIPTION |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 25 | * Check deadlock detection for file locking |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 26 | * |
| 27 | * ALGORITHM |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 28 | * The parent forks off 3 children. The parent controls the children |
| 29 | * with messages via pipes to create a delayed deadlock between the |
| 30 | * second and third child. |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 31 | * |
| 32 | * USAGE |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 33 | * fcntl17 |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 34 | * |
| 35 | * HISTORY |
| 36 | * 07/2001 Ported by Wayne Boyer |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 37 | * 04/2002 Minor fixes by William Jay Huie (testcase name |
plars | 07635bc | 2002-04-18 16:26:43 +0000 | [diff] [blame] | 38 | fcntl05 => fcntl17, check signal return for SIG_ERR) |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 39 | * |
| 40 | * RESTRICTIONS |
| 41 | * None |
| 42 | */ |
| 43 | |
vapier | 5b31d1b | 2006-08-21 06:46:26 +0000 | [diff] [blame] | 44 | #ifndef _GNU_SOURCE |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 45 | #define _GNU_SOURCE |
vapier | 5b31d1b | 2006-08-21 06:46:26 +0000 | [diff] [blame] | 46 | #endif |
| 47 | |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 48 | #include <fcntl.h> |
| 49 | #include <errno.h> |
| 50 | #include <signal.h> |
robbiew | 5aab8a7 | 2003-03-26 18:05:30 +0000 | [diff] [blame] | 51 | #include <sys/stat.h> |
| 52 | #include <sys/types.h> |
mridge | db63921 | 2005-01-04 21:04:11 +0000 | [diff] [blame] | 53 | #include <sys/wait.h> |
subrata_modak | 923b23f | 2009-11-02 13:57:16 +0000 | [diff] [blame] | 54 | #include <inttypes.h> |
| 55 | |
robbiew | 5aab8a7 | 2003-03-26 18:05:30 +0000 | [diff] [blame] | 56 | #include "test.h" |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 57 | |
plars | 07635bc | 2002-04-18 16:26:43 +0000 | [diff] [blame] | 58 | char *TCID = "fcntl17"; |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 59 | int TST_TOTAL = 1; |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 60 | |
| 61 | #define STRINGSIZE 27 |
| 62 | #define STRING "abcdefghijklmnopqrstuvwxyz\n" |
| 63 | #define STOP 0xFFF0 |
| 64 | #define TIME_OUT 10 |
| 65 | |
| 66 | /* global variables */ |
| 67 | int parent_pipe[2]; |
| 68 | int child_pipe1[2]; |
| 69 | int child_pipe2[2]; |
| 70 | int child_pipe3[2]; |
| 71 | int file_fd; |
robbiew | 4673685 | 2003-03-13 15:43:49 +0000 | [diff] [blame] | 72 | pid_t parent_pid, child_pid1, child_pid2, child_pid3; |
plars | 874b422 | 2002-04-18 17:19:16 +0000 | [diff] [blame] | 73 | int child_stat; |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 74 | struct flock lock1 = { (short)F_WRLCK, (short)0, 2, 5, (short)0 }; |
| 75 | struct flock lock2 = { (short)F_WRLCK, (short)0, 9, 5, (short)0 }; |
| 76 | struct flock lock3 = { (short)F_WRLCK, (short)0, 17, 5, (short)0 }; |
| 77 | struct flock lock4 = { (short)F_WRLCK, (short)0, 17, 5, (short)0 }; |
| 78 | struct flock lock5 = { (short)F_WRLCK, (short)0, 2, 14, (short)0 }; |
| 79 | struct flock unlock = { (short)F_UNLCK, (short)0, 0, 0, (short)0 }; |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 80 | |
| 81 | /* prototype declarations */ |
| 82 | int setup(); |
| 83 | void cleanup(); |
| 84 | int parent_wait(); |
| 85 | void parent_free(); |
| 86 | void child_wait(); |
| 87 | void child_free(); |
| 88 | void do_child1(); |
| 89 | void do_child2(); |
| 90 | void do_child3(); |
subrata_modak | f08488f | 2008-11-18 09:38:10 +0000 | [diff] [blame] | 91 | int do_test(struct flock *, pid_t); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 92 | void stop_children(); |
| 93 | void catch_child(); |
| 94 | void catch_alarm(); |
| 95 | char *str_type(); |
| 96 | |
Mike Frysinger | c57fba5 | 2014-04-09 18:56:30 -0400 | [diff] [blame] | 97 | int setup(void) |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 98 | { |
| 99 | char *buf = STRING; |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 100 | char template[PATH_MAX]; |
robbiew | 1e4cf0c | 2005-02-24 17:03:42 +0000 | [diff] [blame] | 101 | struct sigaction act; |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 102 | |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 103 | tst_sig(FORK, DEF_HANDLER, NULL); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 104 | umask(0); |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 105 | TEST_PAUSE; |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 106 | tst_tmpdir(); /* make temp dir and cd to it */ |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 107 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 108 | if (pipe(parent_pipe) < 0) { |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 109 | tst_resm(TFAIL, "Couldn't create parent_pipe! errno = %d", |
plars | caccaf2 | 2002-04-18 16:39:41 +0000 | [diff] [blame] | 110 | errno); |
subrata_modak | 134e896 | 2009-02-26 11:46:54 +0000 | [diff] [blame] | 111 | return 1; |
plars | caccaf2 | 2002-04-18 16:39:41 +0000 | [diff] [blame] | 112 | } |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 113 | if (pipe(child_pipe1) < 0) { |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 114 | tst_resm(TFAIL, "Couldn't create child_pipe1! errno = %d", |
plars | caccaf2 | 2002-04-18 16:39:41 +0000 | [diff] [blame] | 115 | errno); |
subrata_modak | 134e896 | 2009-02-26 11:46:54 +0000 | [diff] [blame] | 116 | return 1; |
plars | caccaf2 | 2002-04-18 16:39:41 +0000 | [diff] [blame] | 117 | } |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 118 | if (pipe(child_pipe2) < 0) { |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 119 | tst_resm(TFAIL, "Couldn't create child_pipe2! errno = %d", |
plars | caccaf2 | 2002-04-18 16:39:41 +0000 | [diff] [blame] | 120 | errno); |
subrata_modak | 134e896 | 2009-02-26 11:46:54 +0000 | [diff] [blame] | 121 | return 1; |
plars | caccaf2 | 2002-04-18 16:39:41 +0000 | [diff] [blame] | 122 | } |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 123 | if (pipe(child_pipe3) < 0) { |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 124 | tst_resm(TFAIL, "Couldn't create child_pipe3! errno = %d", |
plars | caccaf2 | 2002-04-18 16:39:41 +0000 | [diff] [blame] | 125 | errno); |
subrata_modak | 134e896 | 2009-02-26 11:46:54 +0000 | [diff] [blame] | 126 | return 1; |
plars | caccaf2 | 2002-04-18 16:39:41 +0000 | [diff] [blame] | 127 | } |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 128 | parent_pid = getpid(); |
robbiew | dad2271 | 2003-04-16 19:14:05 +0000 | [diff] [blame] | 129 | snprintf(template, PATH_MAX, "fcntl17XXXXXX"); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 130 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 131 | if ((file_fd = mkstemp(template)) < 0) { |
| 132 | tst_resm(TFAIL, "Couldn't open temp file! errno = %d", errno); |
| 133 | } |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 134 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 135 | if (write(file_fd, buf, STRINGSIZE) < 0) { |
| 136 | tst_resm(TFAIL, "Couldn't write to temp file! errno = %d", |
| 137 | errno); |
| 138 | } |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 139 | |
robbiew | 1e4cf0c | 2005-02-24 17:03:42 +0000 | [diff] [blame] | 140 | memset(&act, 0, sizeof(act)); |
| 141 | act.sa_handler = catch_alarm; |
| 142 | sigemptyset(&act.sa_mask); |
| 143 | sigaddset(&act.sa_mask, SIGALRM); |
| 144 | if (sigaction(SIGALRM, &act, NULL) < 0) { |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 145 | tst_resm(TFAIL, "SIGALRM signal setup failed, errno: %d", |
| 146 | errno); |
subrata_modak | 134e896 | 2009-02-26 11:46:54 +0000 | [diff] [blame] | 147 | return 1; |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 148 | } |
| 149 | |
robbiew | 1e4cf0c | 2005-02-24 17:03:42 +0000 | [diff] [blame] | 150 | memset(&act, 0, sizeof(act)); |
| 151 | act.sa_handler = catch_child; |
| 152 | sigemptyset(&act.sa_mask); |
| 153 | sigaddset(&act.sa_mask, SIGCLD); |
| 154 | if (sigaction(SIGCLD, &act, NULL) < 0) { |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 155 | tst_resm(TFAIL, "SIGCLD signal setup failed, errno: %d", errno); |
subrata_modak | 134e896 | 2009-02-26 11:46:54 +0000 | [diff] [blame] | 156 | return 1; |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 157 | } |
subrata_modak | 43337a3 | 2009-02-26 11:43:51 +0000 | [diff] [blame] | 158 | return 0; |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 159 | } |
| 160 | |
Mike Frysinger | c57fba5 | 2014-04-09 18:56:30 -0400 | [diff] [blame] | 161 | void cleanup(void) |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 162 | { |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 163 | close(file_fd); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 164 | tst_rmdir(); |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 165 | |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 166 | } |
| 167 | |
Mike Frysinger | c57fba5 | 2014-04-09 18:56:30 -0400 | [diff] [blame] | 168 | void do_child1(void) |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 169 | { |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 170 | int err; |
mridge | db63921 | 2005-01-04 21:04:11 +0000 | [diff] [blame] | 171 | |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 172 | close(parent_pipe[0]); |
| 173 | close(child_pipe1[1]); |
| 174 | close(child_pipe2[0]); |
| 175 | close(child_pipe2[1]); |
| 176 | close(child_pipe3[0]); |
| 177 | close(child_pipe3[1]); |
| 178 | |
| 179 | child_wait(child_pipe1[0]); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 180 | tst_resm(TINFO, "child 1 starting"); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 181 | if (fcntl(file_fd, F_SETLK, &lock1) < 0) { |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 182 | err = errno; |
| 183 | tst_resm(TINFO, "child 1 lock err %d", err); |
mridge | db63921 | 2005-01-04 21:04:11 +0000 | [diff] [blame] | 184 | parent_free(err); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 185 | } else { |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 186 | tst_resm(TINFO, "child 1 pid %d locked", getpid()); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 187 | parent_free(0); |
| 188 | } |
| 189 | |
| 190 | child_wait(child_pipe1[0]); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 191 | tst_resm(TINFO, "child 1 resuming"); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 192 | fcntl(file_fd, F_SETLK, &unlock); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 193 | tst_resm(TINFO, "child 1 unlocked"); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 194 | |
| 195 | child_wait(child_pipe1[0]); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 196 | tst_resm(TINFO, "child 1 exiting"); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 197 | exit(1); |
| 198 | } |
| 199 | |
Mike Frysinger | c57fba5 | 2014-04-09 18:56:30 -0400 | [diff] [blame] | 200 | void do_child2(void) |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 201 | { |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 202 | int err; |
mridge | db63921 | 2005-01-04 21:04:11 +0000 | [diff] [blame] | 203 | |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 204 | close(parent_pipe[0]); |
| 205 | close(child_pipe1[0]); |
| 206 | close(child_pipe1[1]); |
| 207 | close(child_pipe2[1]); |
| 208 | close(child_pipe3[0]); |
| 209 | close(child_pipe3[1]); |
| 210 | |
| 211 | child_wait(child_pipe2[0]); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 212 | tst_resm(TINFO, "child 2 starting"); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 213 | if (fcntl(file_fd, F_SETLK, &lock2) < 0) { |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 214 | err = errno; |
| 215 | tst_resm(TINFO, "child 2 lock err %d", err); |
mridge | db63921 | 2005-01-04 21:04:11 +0000 | [diff] [blame] | 216 | parent_free(err); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 217 | } else { |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 218 | tst_resm(TINFO, "child 2 pid %d locked", getpid()); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 219 | parent_free(0); |
| 220 | } |
| 221 | |
| 222 | child_wait(child_pipe2[0]); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 223 | tst_resm(TINFO, "child 2 resuming"); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 224 | if (fcntl(file_fd, F_SETLKW, &lock4) < 0) { |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 225 | err = errno; |
| 226 | tst_resm(TINFO, "child 2 lockw err %d", err); |
mridge | db63921 | 2005-01-04 21:04:11 +0000 | [diff] [blame] | 227 | parent_free(err); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 228 | } else { |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 229 | tst_resm(TINFO, "child 2 lockw locked"); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 230 | parent_free(0); |
| 231 | } |
| 232 | |
| 233 | child_wait(child_pipe2[0]); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 234 | tst_resm(TINFO, "child 2 exiting"); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 235 | exit(1); |
| 236 | } |
| 237 | |
Mike Frysinger | c57fba5 | 2014-04-09 18:56:30 -0400 | [diff] [blame] | 238 | void do_child3(void) |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 239 | { |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 240 | int err; |
mridge | db63921 | 2005-01-04 21:04:11 +0000 | [diff] [blame] | 241 | |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 242 | close(parent_pipe[0]); |
| 243 | close(child_pipe1[0]); |
| 244 | close(child_pipe1[1]); |
| 245 | close(child_pipe2[0]); |
| 246 | close(child_pipe2[1]); |
| 247 | close(child_pipe3[1]); |
| 248 | |
| 249 | child_wait(child_pipe3[0]); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 250 | tst_resm(TINFO, "child 3 starting"); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 251 | if (fcntl(file_fd, F_SETLK, &lock3) < 0) { |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 252 | err = errno; |
| 253 | tst_resm(TINFO, "child 3 lock err %d", err); |
mridge | db63921 | 2005-01-04 21:04:11 +0000 | [diff] [blame] | 254 | parent_free(err); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 255 | } else { |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 256 | tst_resm(TINFO, "child 3 pid %d locked", getpid()); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 257 | parent_free(0); |
| 258 | } |
| 259 | |
| 260 | child_wait(child_pipe3[0]); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 261 | tst_resm(TINFO, "child 3 resuming"); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 262 | if (fcntl(file_fd, F_SETLKW, &lock5) < 0) { |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 263 | err = errno; |
| 264 | tst_resm(TINFO, "child 3 lockw err %d", err); |
mridge | db63921 | 2005-01-04 21:04:11 +0000 | [diff] [blame] | 265 | parent_free(err); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 266 | } else { |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 267 | tst_resm(TINFO, "child 3 lockw locked"); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 268 | parent_free(0); |
| 269 | } |
| 270 | |
| 271 | child_wait(child_pipe3[0]); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 272 | tst_resm(TINFO, "child 3 exiting"); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 273 | exit(1); |
| 274 | } |
| 275 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 276 | int do_test(struct flock *lock, pid_t pid) |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 277 | { |
| 278 | struct flock fl; |
| 279 | |
mridge | db63921 | 2005-01-04 21:04:11 +0000 | [diff] [blame] | 280 | fl.l_type = /* lock->l_type */ F_RDLCK; |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 281 | fl.l_whence = lock->l_whence; |
| 282 | fl.l_start = lock->l_start; |
| 283 | fl.l_len = lock->l_len; |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 284 | fl.l_pid = (short)0; |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 285 | if (fcntl(file_fd, F_GETLK, &fl) < 0) { |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 286 | tst_resm(TFAIL, "fcntl on file failed, errno =%d", errno); |
subrata_modak | 134e896 | 2009-02-26 11:46:54 +0000 | [diff] [blame] | 287 | return 1; |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | if (fl.l_type != lock->l_type) { |
| 291 | tst_resm(TFAIL, "lock type is wrong should be %s is %s", |
| 292 | str_type(lock->l_type), str_type(fl.l_type)); |
subrata_modak | 134e896 | 2009-02-26 11:46:54 +0000 | [diff] [blame] | 293 | return 1; |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | if (fl.l_whence != lock->l_whence) { |
| 297 | tst_resm(TFAIL, "lock whence is wrong should be %d is %d", |
| 298 | lock->l_whence, fl.l_whence); |
subrata_modak | 134e896 | 2009-02-26 11:46:54 +0000 | [diff] [blame] | 299 | return 1; |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | if (fl.l_start != lock->l_start) { |
| 303 | tst_resm(TFAIL, "region starts in wrong place, " |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 304 | "should be %" PRId64 " is %" PRId64, |
| 305 | (int64_t) lock->l_start, (int64_t) fl.l_start); |
subrata_modak | 134e896 | 2009-02-26 11:46:54 +0000 | [diff] [blame] | 306 | return 1; |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | if (fl.l_len != lock->l_len) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 310 | tst_resm(TFAIL, |
| 311 | "region length is wrong, should be %" PRId64 " is %" |
| 312 | PRId64, (int64_t) lock->l_len, (int64_t) fl.l_len); |
subrata_modak | 134e896 | 2009-02-26 11:46:54 +0000 | [diff] [blame] | 313 | return 1; |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | if (fl.l_pid != pid) { |
| 317 | tst_resm(TFAIL, "locking pid is wrong, should be %d is %d", |
| 318 | pid, fl.l_pid); |
subrata_modak | 134e896 | 2009-02-26 11:46:54 +0000 | [diff] [blame] | 319 | return 1; |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 320 | } |
subrata_modak | 43337a3 | 2009-02-26 11:43:51 +0000 | [diff] [blame] | 321 | return 0; |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 322 | } |
| 323 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 324 | char *str_type(int type) |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 325 | { |
| 326 | static char buf[20]; |
| 327 | |
| 328 | switch (type) { |
mridge | db63921 | 2005-01-04 21:04:11 +0000 | [diff] [blame] | 329 | case F_RDLCK: |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 330 | return ("F_RDLCK"); |
mridge | db63921 | 2005-01-04 21:04:11 +0000 | [diff] [blame] | 331 | case F_WRLCK: |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 332 | return ("F_WRLCK"); |
mridge | db63921 | 2005-01-04 21:04:11 +0000 | [diff] [blame] | 333 | case F_UNLCK: |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 334 | return ("F_UNLCK"); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 335 | default: |
| 336 | sprintf(buf, "BAD VALUE: %d", type); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 337 | return (buf); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 338 | } |
| 339 | } |
| 340 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 341 | void parent_free(int arg) |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 342 | { |
| 343 | if (write(parent_pipe[1], &arg, sizeof(arg)) != sizeof(arg)) { |
| 344 | tst_resm(TFAIL, "couldn't send message to parent"); |
| 345 | exit(1); |
| 346 | } |
| 347 | } |
| 348 | |
Mike Frysinger | c57fba5 | 2014-04-09 18:56:30 -0400 | [diff] [blame] | 349 | int parent_wait(void) |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 350 | { |
| 351 | int arg; |
| 352 | |
| 353 | if (read(parent_pipe[0], &arg, sizeof(arg)) != sizeof(arg)) { |
| 354 | tst_resm(TFAIL, "parent_wait() failed"); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 355 | return (errno); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 356 | } |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 357 | return (arg); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 358 | } |
| 359 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 360 | void child_free(int fd, int arg) |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 361 | { |
| 362 | if (write(fd, &arg, sizeof(arg)) != sizeof(arg)) { |
| 363 | tst_resm(TFAIL, "couldn't send message to child"); |
| 364 | exit(1); |
| 365 | } |
| 366 | } |
| 367 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 368 | void child_wait(int fd) |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 369 | { |
| 370 | int arg; |
| 371 | |
| 372 | if (read(fd, &arg, sizeof(arg)) != sizeof(arg)) { |
| 373 | tst_resm(TFAIL, "couldn't get message from parent"); |
| 374 | exit(1); |
| 375 | } else if (arg == (short)STOP) { |
| 376 | exit(0); |
| 377 | } |
| 378 | } |
| 379 | |
Mike Frysinger | c57fba5 | 2014-04-09 18:56:30 -0400 | [diff] [blame] | 380 | void stop_children(void) |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 381 | { |
| 382 | int arg; |
| 383 | |
Mike Frysinger | e61ddba | 2014-04-09 23:24:32 -0400 | [diff] [blame] | 384 | signal(SIGCLD, SIG_DFL); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 385 | arg = STOP; |
| 386 | child_free(child_pipe1[1], arg); |
| 387 | child_free(child_pipe2[1], arg); |
| 388 | child_free(child_pipe3[1], arg); |
| 389 | wait(0); |
| 390 | } |
| 391 | |
Mike Frysinger | c57fba5 | 2014-04-09 18:56:30 -0400 | [diff] [blame] | 392 | void catch_child(void) |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 393 | { |
| 394 | tst_resm(TFAIL, "Unexpected death of child process"); |
| 395 | cleanup(); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 396 | } |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 397 | |
Mike Frysinger | c57fba5 | 2014-04-09 18:56:30 -0400 | [diff] [blame] | 398 | void catch_alarm(void) |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 399 | { |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 400 | sighold(SIGCHLD); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 401 | /* |
| 402 | * Timer has runout and the children have not detected the deadlock. |
| 403 | * Need to kill the kids and exit |
| 404 | */ |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 405 | if (child_pid1 != 0 && (kill(child_pid1, SIGKILL)) < 0) { |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 406 | tst_resm(TFAIL, "Attempt to signal child 1 failed."); |
| 407 | } |
| 408 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 409 | if (child_pid2 != 0 && (kill(child_pid2, SIGKILL)) < 0) { |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 410 | tst_resm(TFAIL, "Attempt to signal child 2 failed."); |
| 411 | } |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 412 | if (child_pid3 != 0 && (kill(child_pid3, SIGKILL)) < 0) { |
mridge | db63921 | 2005-01-04 21:04:11 +0000 | [diff] [blame] | 413 | tst_resm(TFAIL, "Attempt to signal child 2 failed."); |
| 414 | } |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 415 | tst_resm(TFAIL, "Alarm expired, deadlock not detected"); |
| 416 | tst_resm(TWARN, "You may need to kill child processes by hand"); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 417 | cleanup(); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 418 | } |
robbiew | 5aab8a7 | 2003-03-26 18:05:30 +0000 | [diff] [blame] | 419 | |
| 420 | int main(int ac, char **av) |
| 421 | { |
| 422 | int ans; |
Cyril Hrubis | 89af32a | 2012-10-24 16:39:11 +0200 | [diff] [blame] | 423 | int lc; |
Cyril Hrubis | 0b9589f | 2014-05-27 17:40:33 +0200 | [diff] [blame] | 424 | const char *msg; |
robbiew | 5aab8a7 | 2003-03-26 18:05:30 +0000 | [diff] [blame] | 425 | int fail = 0; |
| 426 | |
Garrett Cooper | 45e285d | 2010-11-22 12:19:25 -0800 | [diff] [blame] | 427 | if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { |
Garrett Cooper | 60fa801 | 2010-11-22 13:50:58 -0800 | [diff] [blame] | 428 | tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); |
robbiew | 5aab8a7 | 2003-03-26 18:05:30 +0000 | [diff] [blame] | 429 | } |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 430 | #ifdef UCLINUX |
| 431 | maybe_run_child(&do_child1, "nddddddddd", 1, &file_fd, |
| 432 | &parent_pipe[0], &parent_pipe[1], |
| 433 | &child_pipe1[0], &child_pipe1[1], |
| 434 | &child_pipe2[0], &child_pipe2[1], |
| 435 | &child_pipe3[0], &child_pipe3[1]); |
| 436 | maybe_run_child(&do_child2, "nddddddddd", 2, &file_fd, |
| 437 | &parent_pipe[0], &parent_pipe[1], |
| 438 | &child_pipe1[0], &child_pipe1[1], |
| 439 | &child_pipe2[0], &child_pipe2[1], |
| 440 | &child_pipe3[0], &child_pipe3[1]); |
| 441 | maybe_run_child(&do_child3, "nddddddddd", 3, &file_fd, |
| 442 | &parent_pipe[0], &parent_pipe[1], |
| 443 | &child_pipe1[0], &child_pipe1[1], |
| 444 | &child_pipe2[0], &child_pipe2[1], |
| 445 | &child_pipe3[0], &child_pipe3[1]); |
| 446 | #endif |
| 447 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 448 | if (setup()) { /* global testup */ |
robbiew | 5aab8a7 | 2003-03-26 18:05:30 +0000 | [diff] [blame] | 449 | tst_resm(TINFO, "setup failed"); |
| 450 | cleanup(); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 451 | } |
robbiew | 5aab8a7 | 2003-03-26 18:05:30 +0000 | [diff] [blame] | 452 | |
| 453 | /* check for looping state if -i option is given */ |
| 454 | for (lc = 0; TEST_LOOPING(lc); lc++) { |
Caspar Zhang | d59a659 | 2013-03-07 14:59:12 +0800 | [diff] [blame] | 455 | /* reset tst_count in case we are looping */ |
| 456 | tst_count = 0; |
robbiew | 5aab8a7 | 2003-03-26 18:05:30 +0000 | [diff] [blame] | 457 | |
| 458 | tst_resm(TINFO, "Enter preparation phase"); |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 459 | if ((child_pid1 = FORK_OR_VFORK()) == 0) { /* first child */ |
| 460 | #ifdef UCLINUX |
| 461 | if (self_exec(av[0], "nddddddddd", 1, file_fd, |
| 462 | parent_pipe[0], parent_pipe[1], |
| 463 | child_pipe1[0], child_pipe1[1], |
| 464 | child_pipe2[0], child_pipe2[1], |
| 465 | child_pipe3[0], child_pipe3[1]) < 0) { |
| 466 | perror("self_exec failed, child 1"); |
| 467 | cleanup(); |
| 468 | } |
| 469 | #else |
robbiew | 5aab8a7 | 2003-03-26 18:05:30 +0000 | [diff] [blame] | 470 | do_child1(); |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 471 | #endif |
robbiew | 5aab8a7 | 2003-03-26 18:05:30 +0000 | [diff] [blame] | 472 | } else if (child_pid1 < 0) { |
| 473 | perror("Fork failed: child 1"); |
| 474 | cleanup(); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 475 | } |
robbiew | 5aab8a7 | 2003-03-26 18:05:30 +0000 | [diff] [blame] | 476 | |
| 477 | /* parent */ |
| 478 | |
| 479 | if ((child_pid2 = fork()) == 0) { /* second child */ |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 480 | #ifdef UCLINUX |
| 481 | if (self_exec(av[0], "nddddddddd", 2, file_fd, |
| 482 | parent_pipe[0], parent_pipe[1], |
| 483 | child_pipe1[0], child_pipe1[1], |
| 484 | child_pipe2[0], child_pipe2[1], |
| 485 | child_pipe3[0], child_pipe3[1]) < 0) { |
| 486 | perror("self_exec failed, child 2"); |
| 487 | cleanup(); |
| 488 | } |
| 489 | #else |
robbiew | 5aab8a7 | 2003-03-26 18:05:30 +0000 | [diff] [blame] | 490 | do_child2(); |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 491 | #endif |
robbiew | 5aab8a7 | 2003-03-26 18:05:30 +0000 | [diff] [blame] | 492 | } else if (child_pid2 < 0) { |
| 493 | perror("Fork failed: child 2"); |
| 494 | if ((kill(child_pid1, SIGKILL)) < 0) { |
| 495 | tst_resm(TFAIL, "Attempt to signal child " |
| 496 | "1 failed"); |
| 497 | } |
| 498 | cleanup(); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 499 | } |
robbiew | 5aab8a7 | 2003-03-26 18:05:30 +0000 | [diff] [blame] | 500 | |
| 501 | /* parent */ |
| 502 | |
| 503 | if ((child_pid3 = fork()) == 0) { /* third child */ |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 504 | #ifdef UCLINUX |
| 505 | if (self_exec(av[0], "nddddddddd", 3, file_fd, |
| 506 | parent_pipe[0], parent_pipe[1], |
| 507 | child_pipe1[0], child_pipe1[1], |
| 508 | child_pipe2[0], child_pipe2[1], |
| 509 | child_pipe3[0], child_pipe3[1]) < 0) { |
| 510 | perror("self_exec failed, child 3"); |
| 511 | cleanup(); |
| 512 | } |
| 513 | #else |
| 514 | do_child3(); |
| 515 | #endif |
robbiew | 5aab8a7 | 2003-03-26 18:05:30 +0000 | [diff] [blame] | 516 | do_child3(); |
| 517 | } else if (child_pid3 < 0) { |
| 518 | perror("Fork failed: child 3"); |
| 519 | if ((kill(child_pid1, SIGKILL)) < 0) { |
| 520 | tst_resm(TFAIL, "Attempt to signal child " |
| 521 | "1 failed"); |
| 522 | } |
| 523 | if ((kill(child_pid2, SIGKILL)) < 0) { |
| 524 | tst_resm(TFAIL, "Attempt to signal child 2 " |
| 525 | "failed"); |
| 526 | } |
| 527 | cleanup(); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 528 | } |
robbiew | 5aab8a7 | 2003-03-26 18:05:30 +0000 | [diff] [blame] | 529 | /* parent */ |
| 530 | |
| 531 | close(parent_pipe[1]); |
| 532 | close(child_pipe1[0]); |
| 533 | close(child_pipe2[0]); |
| 534 | close(child_pipe3[0]); |
| 535 | tst_resm(TINFO, "Exit preparation phase"); |
| 536 | |
mridge | db63921 | 2005-01-04 21:04:11 +0000 | [diff] [blame] | 537 | /* //block1: */ |
robbiew | 5aab8a7 | 2003-03-26 18:05:30 +0000 | [diff] [blame] | 538 | tst_resm(TINFO, "Enter block 1"); |
| 539 | fail = 0; |
| 540 | /* |
| 541 | * child 1 puts first lock (bytes 2-7) |
| 542 | */ |
| 543 | child_free(child_pipe1[1], 0); |
| 544 | if (parent_wait()) { |
| 545 | tst_resm(TFAIL, "didn't set first child's lock, " |
| 546 | "errno: %d", errno); |
| 547 | } |
| 548 | if (do_test(&lock1, child_pid1)) { |
| 549 | tst_resm(TINFO, "do_test failed child 1"); |
| 550 | fail = 1; |
| 551 | } |
| 552 | |
| 553 | /* |
| 554 | * child 2 puts second lock (bytes 9-14) |
| 555 | */ |
| 556 | child_free(child_pipe2[1], 0); |
| 557 | if (parent_wait()) { |
| 558 | tst_resm(TINFO, "didn't set second child's lock, " |
| 559 | "errno: %d", errno); |
| 560 | fail = 1; |
| 561 | } |
| 562 | if (do_test(&lock2, child_pid2)) { |
| 563 | tst_resm(TINFO, "do_test failed child 2"); |
| 564 | fail = 1; |
| 565 | } |
| 566 | |
| 567 | /* |
| 568 | * child 3 puts third lock (bytes 17-22) |
| 569 | */ |
| 570 | child_free(child_pipe3[1], 0); |
| 571 | if (parent_wait()) { |
| 572 | tst_resm(TFAIL, "didn't set third child's lock, " |
| 573 | "errno: %d", errno); |
| 574 | fail = 1; |
| 575 | } |
| 576 | if (do_test(&lock3, child_pid3)) { |
| 577 | tst_resm(TINFO, "do_test failed child 3"); |
| 578 | fail = 1; |
| 579 | } |
| 580 | |
| 581 | /* |
| 582 | * child 2 tries to lock same range as |
| 583 | * child 3's first lock. |
| 584 | */ |
| 585 | child_free(child_pipe2[1], 0); |
| 586 | |
| 587 | /* |
| 588 | * child 3 tries to lock same range as |
| 589 | * child 1 and child 2's first locks. |
| 590 | */ |
| 591 | child_free(child_pipe3[1], 0); |
| 592 | |
| 593 | /* |
| 594 | * Tell child 1 to release its lock. This should cause a |
| 595 | * delayed deadlock between child 2 and child 3. |
| 596 | */ |
| 597 | child_free(child_pipe1[1], 0); |
| 598 | |
| 599 | /* |
| 600 | * Setup an alarm to go off in case the deadlock is not |
| 601 | * detected |
| 602 | */ |
| 603 | alarm(TIME_OUT); |
| 604 | |
| 605 | /* |
| 606 | * should get a message from child 3 telling that its |
| 607 | * second lock EDEADLOCK |
| 608 | */ |
| 609 | if ((ans = parent_wait()) != EDEADLK) { |
| 610 | tst_resm(TFAIL, "child 2 didn't deadlock, " |
| 611 | "returned: %d", ans); |
| 612 | fail = 1; |
| 613 | } |
| 614 | |
| 615 | /* |
| 616 | * Double check that lock 2 and lock 3 are still right |
| 617 | */ |
| 618 | do_test(&lock2, child_pid2); |
| 619 | do_test(&lock3, child_pid3); |
| 620 | |
| 621 | stop_children(); |
robbiew | 5aab8a7 | 2003-03-26 18:05:30 +0000 | [diff] [blame] | 622 | if (fail) { |
| 623 | tst_resm(TINFO, "Block 1 FAILED"); |
| 624 | } else { |
| 625 | tst_resm(TINFO, "Block 1 PASSED"); |
| 626 | } |
| 627 | tst_resm(TINFO, "Exit block 1"); |
| 628 | } |
| 629 | waitpid(child_pid1, &child_stat, 0); |
| 630 | waitpid(child_pid2, &child_stat, 0); |
| 631 | waitpid(child_pid3, &child_stat, 0); |
| 632 | cleanup(); |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 633 | tst_exit(); |
Chris Dearman | ec6edca | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 634 | } |