blob: 52817f4f3f3215069867252a2f0838a594d9de2a [file] [log] [blame]
plars865695b2001-08-27 22:15:12 +00001/*
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 Gao4548c6c2012-10-19 18:03:36 +080017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
plars865695b2001-08-27 22:15:12 +000018 */
19
20/*
21 * NAME
22 * writev01.c
23 *
24 * DESCRIPTION
25 * Testcase to check the basic functionality of writev(2) system call.
26 *
27 * ALGORITHM
Garrett Cooper2aca6fc2010-12-19 03:12:40 -080028 * Create a IO vector, and attempt to writev various components of it.
plars865695b2001-08-27 22:15:12 +000029 *
30 * USAGE: <for command-line>
31 * writev01 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
32 * where, -c n : Run n copies concurrently.
33 * -e : Turn on errno logging.
34 * -i n : Execute test n times.
35 * -I x : Execute test for x seconds.
36 * -P x : Pause for x seconds between iterations.
37 * -t : Turn on syscall timing.
38 *
39 * History
40 * 07/2001 John George
41 * -Ported
robbiew4644c7e2002-04-26 14:33:32 +000042 * 04/2002 wjhuie sigset cleanups
robbiew51281002002-06-20 17:02:19 +000043 * 06/2002 Shaobo Li
44 * fix testcase 7, add each testcase comment.
plars865695b2001-08-27 22:15:12 +000045 *
46 * Restrictions
47 * None
48 */
49
50#include <stdio.h>
plars29bcde82002-10-07 17:21:48 +000051#include <sys/types.h>
plars20bc5f22002-10-10 17:37:56 +000052#include <signal.h>
plars865695b2001-08-27 22:15:12 +000053#include <sys/uio.h>
54#include <sys/fcntl.h>
55#include <memory.h>
56#include <errno.h>
Garrett Coopere8530df2010-12-21 11:37:57 -080057#include "test.h"
58#include "usctest.h"
robbiewb73a6b72003-11-17 15:21:18 +000059#include <sys/mman.h>
plars865695b2001-08-27 22:15:12 +000060
61#define K_1 1024
62#define M_1 K_1 * K_1
63#define G_1 M_1 * K_1
64
65#define NBUFS 4
subrata_modak56207ce2009-03-23 13:35:39 +000066#define CHUNK 64 /* single chunk */
plars865695b2001-08-27 22:15:12 +000067#define MAX_IOVEC 16
68#define DATA_FILE "writev_data_file"
69
70char buf1[K_1], buf2[K_1], buf3[K_1];
71
72struct iovec wr_iovec[MAX_IOVEC] = {
subrata_modak56207ce2009-03-23 13:35:39 +000073 /* iov_base *//* iov_len */
plars865695b2001-08-27 22:15:12 +000074
75 /* testcase# 1 */
subrata_modak56207ce2009-03-23 13:35:39 +000076 {buf1, -1},
77 {(buf1 + CHUNK), CHUNK},
78 {(buf1 + CHUNK * 2), CHUNK},
plars865695b2001-08-27 22:15:12 +000079
80 /* testcase# 2 */
subrata_modak56207ce2009-03-23 13:35:39 +000081 {(buf1 + CHUNK * 3), G_1},
82 {(buf1 + CHUNK * 4), G_1},
83 {(buf1 + CHUNK * 5), G_1},
plars865695b2001-08-27 22:15:12 +000084
85 /* testcase# 3 */
subrata_modak56207ce2009-03-23 13:35:39 +000086 {(buf1 + CHUNK * 6), CHUNK},
87 {(caddr_t) - 1, CHUNK},
88 {(buf1 + CHUNK * 8), CHUNK},
plars865695b2001-08-27 22:15:12 +000089
90 /* testcase# 4 */
subrata_modak56207ce2009-03-23 13:35:39 +000091 {(buf1 + CHUNK * 9), CHUNK},
plars865695b2001-08-27 22:15:12 +000092
93 /* testcase# 5 */
subrata_modak56207ce2009-03-23 13:35:39 +000094 {(buf1 + CHUNK * 10), CHUNK},
plars865695b2001-08-27 22:15:12 +000095
96 /* testcase# 6 */
subrata_modak56207ce2009-03-23 13:35:39 +000097 {(buf1 + CHUNK * 11), CHUNK},
plars865695b2001-08-27 22:15:12 +000098
99 /* testcase# 7 */
subrata_modak56207ce2009-03-23 13:35:39 +0000100 {(buf1 + CHUNK * 12), CHUNK},
plars865695b2001-08-27 22:15:12 +0000101
102 /* testcase# 8 */
subrata_modak56207ce2009-03-23 13:35:39 +0000103 {(buf1 + CHUNK * 13), 0},
plars865695b2001-08-27 22:15:12 +0000104
robbiew51281002002-06-20 17:02:19 +0000105 /* testcase# 7 */
subrata_modak56207ce2009-03-23 13:35:39 +0000106 {(caddr_t) NULL, 0},
107 {(caddr_t) NULL, 0}
plars865695b2001-08-27 22:15:12 +0000108};
109
110char name[K_1], f_name[K_1];
111
subrata_modak56207ce2009-03-23 13:35:39 +0000112char *bad_addr = 0;
robbiewb73a6b72003-11-17 15:21:18 +0000113
plars865695b2001-08-27 22:15:12 +0000114/* 0 terminated list of expected errnos */
subrata_modak56207ce2009-03-23 13:35:39 +0000115int exp_enos[] = { 14, 22, 32, 77, 0 };
plars865695b2001-08-27 22:15:12 +0000116
117int fd[4], in_sighandler;
subrata_modak56207ce2009-03-23 13:35:39 +0000118int pfd[2]; /* pipe fd's */
plars865695b2001-08-27 22:15:12 +0000119char *buf_list[NBUFS];
plars865695b2001-08-27 22:15:12 +0000120
121void sighandler(int);
plars865695b2001-08-27 22:15:12 +0000122int fill_mem(char *, int, int);
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800123void init_buffs(char *[]);
plars865695b2001-08-27 22:15:12 +0000124void setup(void);
125void cleanup(void);
126
127char *TCID = "writev01";
128int TST_TOTAL = 1;
plars865695b2001-08-27 22:15:12 +0000129
robbiew7d5c5172003-03-27 22:54:57 +0000130int main(int argc, char **argv)
plars865695b2001-08-27 22:15:12 +0000131{
132 int nbytes, ret;
133
subrata_modak56207ce2009-03-23 13:35:39 +0000134 int lc; /* loop counter */
135 char *msg; /* message returned from parse_opts */
plars865695b2001-08-27 22:15:12 +0000136
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800137 if ((msg = parse_opts(argc, argv, NULL, NULL)) != NULL)
Garrett Cooper60fa8012010-11-22 13:50:58 -0800138 tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
plars865695b2001-08-27 22:15:12 +0000139
plars865695b2001-08-27 22:15:12 +0000140 setup();
141
plars865695b2001-08-27 22:15:12 +0000142 for (lc = 0; TEST_LOOPING(lc); lc++) {
143
plars865695b2001-08-27 22:15:12 +0000144 Tst_count = 0;
145
146 buf_list[0] = buf1;
147 buf_list[1] = buf2;
148 buf_list[2] = buf3;
Garrett Cooper45e285d2010-11-22 12:19:25 -0800149 buf_list[3] = NULL;
plars865695b2001-08-27 22:15:12 +0000150
subrata_modak56207ce2009-03-23 13:35:39 +0000151 fd[1] = -1; /* Invalid file descriptor */
plars865695b2001-08-27 22:15:12 +0000152
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800153 if (signal(SIGTERM, sighandler) == SIG_ERR)
154 tst_brkm(TBROK|TERRNO, cleanup,
155 "signal(SIGTERM, ..) failed");
plars865695b2001-08-27 22:15:12 +0000156
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800157 if (signal(SIGPIPE, sighandler) == SIG_ERR)
158 tst_brkm(TBROK|TERRNO, cleanup,
159 "signal(SIGPIPE, ..) failed");
plars865695b2001-08-27 22:15:12 +0000160
161 init_buffs(buf_list);
162
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800163 if ((fd[0] = open(f_name, O_WRONLY | O_CREAT, 0666)) == -1)
164 tst_brkm(TBROK|TERRNO, cleanup,
165 "open(.., O_WRONLY|O_CREAT, ..) failed");
166 else
167 if ((nbytes = write(fd[0], buf_list[2], K_1)) != K_1)
168 tst_brkm(TBROK|TERRNO, cleanup, "write failed");
plars865695b2001-08-27 22:15:12 +0000169
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800170 if (close(fd[0]) == -1)
171 tst_brkm(TBROK|TERRNO, cleanup, "close failed");
plars865695b2001-08-27 22:15:12 +0000172
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800173 if ((fd[0] = open(f_name, O_RDWR, 0666)) == -1)
174 tst_brkm(TBROK|TERRNO, cleanup, "open failed");
175//block1: /* given vector length -1, writev return EINVAL. */
176 tst_resm(TPASS, "Enter Block 1");
plars865695b2001-08-27 22:15:12 +0000177
178 TEST(writev(fd[0], wr_iovec, 1));
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800179 if (TEST_RETURN == -1) {
180 if (TEST_ERRNO == EINVAL)
181 tst_resm(TPASS, "Received EINVAL as expected");
182 else
plars865695b2001-08-27 22:15:12 +0000183 tst_resm(TFAIL, "Expected errno = EINVAL, "
184 "got %d", TEST_ERRNO);
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800185 } else
186 tst_resm(TFAIL, "writev failed to fail");
plars865695b2001-08-27 22:15:12 +0000187 tst_resm(TINFO, "Exit block 1");
188
robbiew7d5c5172003-03-27 22:54:57 +0000189//block2:
subrata_modak56207ce2009-03-23 13:35:39 +0000190 /* This testcases doesn't look like what it intent to do
191 * 1. it is not using the wr_iovec initialized
192 * 2. read() and following message is not consistent
193 */
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800194 tst_resm(TPASS, "Enter block 2");
plars865695b2001-08-27 22:15:12 +0000195
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800196 if (lseek(fd[0], CHUNK * 6, 0) == -1)
197 tst_resm(TBROK|TERRNO, "block2: 1st lseek failed");
plars865695b2001-08-27 22:15:12 +0000198
199 if ((ret = writev(fd[0], (wr_iovec + 6), 3)) == CHUNK) {
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800200 if (lseek(fd[0], CHUNK * 6, 0) == -1)
201 tst_brkm(TBROK|TERRNO, cleanup,
202 "block2: 2nd lseek failed");
203 if ((nbytes = read(fd[0], buf_list[0], CHUNK)) !=
204 CHUNK)
205 tst_resm(TFAIL, "read failed; expected nbytes "
206 "= 1024, got = %d", nbytes);
207 else if (memcmp((buf_list[0] + CHUNK * 6),
plars865695b2001-08-27 22:15:12 +0000208 (buf_list[2] + CHUNK * 6),
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800209 CHUNK) != 0)
210 tst_resm(TFAIL, "writev over "
plars865695b2001-08-27 22:15:12 +0000211 "wrote %s", f_name);
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800212 } else
213 tst_resm(TFAIL|TERRNO, "writev failed unexpectedly");
plars865695b2001-08-27 22:15:12 +0000214 tst_resm(TINFO, "Exit block 2");
215
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800216//block3: /* given 1 bad vector buffer with good ones, writev success */
217 tst_resm(TPASS, "Enter block 3");
plars865695b2001-08-27 22:15:12 +0000218
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800219 if (lseek(fd[0], CHUNK * 6, 0) == -1)
220 tst_brkm(TBROK|TERRNO, cleanup,
221 "block3: 1st lseek failed");
222 if ((nbytes = writev(fd[0], (wr_iovec + 6), 3)) == -1) {
223 if (errno == EFAULT)
plars865695b2001-08-27 22:15:12 +0000224 tst_resm(TFAIL, "Got EFAULT");
plars865695b2001-08-27 22:15:12 +0000225 }
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800226 if (lseek(fd[0], 0, 0) == -1)
227 tst_brkm(TBROK, cleanup, "block3: 2nd lseek failed");
plars865695b2001-08-27 22:15:12 +0000228 if ((nbytes = read(fd[0], buf_list[0], K_1)) != K_1) {
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800229 tst_resm(TFAIL|TERRNO,
230 "read failed; expected nbytes = 1024, got = %d",
231 nbytes);
subrata_modak56207ce2009-03-23 13:35:39 +0000232 } else if (memcmp((buf_list[0] + CHUNK * 6),
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800233 (buf_list[2] + CHUNK * 6), CHUNK * 3) != 0)
234 tst_resm(TFAIL, "writev overwrote file");
plars865695b2001-08-27 22:15:12 +0000235
plars865695b2001-08-27 22:15:12 +0000236 tst_resm(TINFO, "Exit block 3");
237
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800238//block4: /* given bad file discriptor, writev return EBADF. */
239 tst_resm(TPASS, "Enter block 4");
plars865695b2001-08-27 22:15:12 +0000240
241 TEST(writev(fd[1], (wr_iovec + 9), 1));
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800242 if (TEST_RETURN == -1) {
243 if (TEST_ERRNO == EBADF)
244 tst_resm(TPASS, "Received EBADF as expected");
245 else
plars865695b2001-08-27 22:15:12 +0000246 tst_resm(TFAIL, "expected errno = EBADF, "
247 "got %d", TEST_ERRNO);
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800248 } else
249 tst_resm(TFAIL, "writev returned a "
plars865695b2001-08-27 22:15:12 +0000250 "positive value");
plars865695b2001-08-27 22:15:12 +0000251
plars865695b2001-08-27 22:15:12 +0000252 tst_resm(TINFO, "Exit block 4");
253
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800254//block5: /* given invalid vector count, writev return EINVAL */
255 tst_resm(TPASS, "Enter block 5");
plars865695b2001-08-27 22:15:12 +0000256
257 TEST(writev(fd[0], (wr_iovec + 10), -1));
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800258 if (TEST_RETURN == -1) {
259 if (TEST_ERRNO == EINVAL)
260 tst_resm(TPASS, "Received EINVAL as expected");
261 else
plars865695b2001-08-27 22:15:12 +0000262 tst_resm(TFAIL, "expected errno = EINVAL, "
263 "got %d", TEST_ERRNO);
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800264 } else
265 tst_resm(TFAIL, "writev returned a "
plars865695b2001-08-27 22:15:12 +0000266 "positive value");
plars865695b2001-08-27 22:15:12 +0000267
plars865695b2001-08-27 22:15:12 +0000268 tst_resm(TINFO, "Exit block 5");
269
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800270//block6: /* given no buffer vector, writev success */
271 tst_resm(TPASS, "Enter block 6");
plars865695b2001-08-27 22:15:12 +0000272
273 TEST(writev(fd[0], (wr_iovec + 11), 0));
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800274 if (TEST_RETURN == -1)
275 tst_resm(TFAIL|TTERRNO, "writev failed");
276 else
277 tst_resm(TPASS, "writev wrote 0 iovectors");
plars865695b2001-08-27 22:15:12 +0000278
plars865695b2001-08-27 22:15:12 +0000279 tst_resm(TINFO, "Exit block 6");
280
robbiew7d5c5172003-03-27 22:54:57 +0000281//block7:
subrata_modak56207ce2009-03-23 13:35:39 +0000282 /* given 4 vectors, 2 are NULL, 1 with 0 length and 1 with fixed length,
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800283 * writev success writing fixed length.
subrata_modak56207ce2009-03-23 13:35:39 +0000284 */
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800285 tst_resm(TPASS, "Enter block 7");
plars865695b2001-08-27 22:15:12 +0000286
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800287 if (lseek(fd[0], CHUNK * 12, 0) == -1)
288 tst_resm(TBROK, "lseek failed");
289 else if ((ret = writev(fd[0], (wr_iovec + 12), 4)) != CHUNK)
290 tst_resm(TFAIL, "writev failed writing %d bytes, "
plars865695b2001-08-27 22:15:12 +0000291 "followed by two NULL vectors", CHUNK);
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800292 else
plars865695b2001-08-27 22:15:12 +0000293 tst_resm(TPASS, "writev passed writing %d bytes, "
294 "followed by two NULL vectors", CHUNK);
plars865695b2001-08-27 22:15:12 +0000295
plars865695b2001-08-27 22:15:12 +0000296 tst_resm(TINFO, "Exit block 7");
297
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800298//block8: /* try to write to a closed pipe, writev return EPIPE. */
299 tst_resm(TPASS, "Enter block 8");
plars865695b2001-08-27 22:15:12 +0000300
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800301 if (pipe(pfd) == -1)
302 tst_resm(TFAIL|TERRNO, "pipe failed");
303 else {
304 if (close(pfd[0]) == -1)
305 tst_resm(TFAIL|TERRNO, "close failed");
306 else if (writev(pfd[1], (wr_iovec + 12), 1) == -1 &&
307 in_sighandler) {
308 if (errno == EPIPE)
309 tst_resm(TPASS, "Received EPIPE as "
subrata_modak56207ce2009-03-23 13:35:39 +0000310 "expected");
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800311 else
312 tst_resm(TFAIL|TERRNO,
313 "didn't get EPIPE");
314 } else
315 tst_resm(TFAIL, "writev returned a positive "
316 "value");
plars865695b2001-08-27 22:15:12 +0000317 }
318 tst_resm(TINFO, "Exit block 8");
319 }
320 cleanup();
Garrett Cooper7d0a4a52010-12-16 10:05:08 -0800321 tst_exit();
plars865695b2001-08-27 22:15:12 +0000322}
323
subrata_modak56207ce2009-03-23 13:35:39 +0000324void setup(void)
plars865695b2001-08-27 22:15:12 +0000325{
Garrett Cooper2c282152010-12-16 00:55:50 -0800326
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800327 tst_sig(FORK, sighandler, cleanup);
plars865695b2001-08-27 22:15:12 +0000328
plars865695b2001-08-27 22:15:12 +0000329 TEST_EXP_ENOS(exp_enos);
330
plars865695b2001-08-27 22:15:12 +0000331 TEST_PAUSE;
332
plars865695b2001-08-27 22:15:12 +0000333 tst_tmpdir();
334
335 strcpy(name, DATA_FILE);
336 sprintf(f_name, "%s.%d", name, getpid());
robbiewb73a6b72003-11-17 15:21:18 +0000337
subrata_modak56207ce2009-03-23 13:35:39 +0000338 bad_addr = mmap(0, 1, PROT_NONE,
339 MAP_PRIVATE_EXCEPT_UCLINUX | MAP_ANONYMOUS, 0, 0);
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800340 if (bad_addr == MAP_FAILED)
341 tst_brkm(TBROK|TERRNO, cleanup, "mmap failed");
subrata_modak56207ce2009-03-23 13:35:39 +0000342 wr_iovec[7].iov_base = bad_addr;
robbiewb73a6b72003-11-17 15:21:18 +0000343
plars865695b2001-08-27 22:15:12 +0000344}
345
subrata_modak56207ce2009-03-23 13:35:39 +0000346void cleanup(void)
plars865695b2001-08-27 22:15:12 +0000347{
plars865695b2001-08-27 22:15:12 +0000348 TEST_CLEANUP;
349
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800350 if (munmap(bad_addr, 1) == -1)
351 tst_resm(TBROK|TERRNO, "munmap failed");
352
353 close(fd[0]);
354 close(fd[1]);
355
356 if (unlink(f_name) == -1)
357 tst_resm(TBROK|TERRNO, "unlink failed");
358
plars865695b2001-08-27 22:15:12 +0000359 tst_rmdir();
360
plars865695b2001-08-27 22:15:12 +0000361}
362
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800363void init_buffs(char *pbufs[])
plars865695b2001-08-27 22:15:12 +0000364{
365 int i;
366
Garrett Cooper45e285d2010-11-22 12:19:25 -0800367 for (i = 0; pbufs[i] != NULL; i++) {
plars865695b2001-08-27 22:15:12 +0000368 switch (i) {
369 case 0:
subrata_modak56207ce2009-03-23 13:35:39 +0000370
371 case 1:
372 fill_mem(pbufs[i], 0, 1);
plars865695b2001-08-27 22:15:12 +0000373 break;
374
subrata_modak56207ce2009-03-23 13:35:39 +0000375 case 2:
376 fill_mem(pbufs[i], 1, 0);
377 break;
378
379 default:
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800380 tst_brkm(TBROK, cleanup, "error detected: init_buffs");
381 }
plars865695b2001-08-27 22:15:12 +0000382 }
plars865695b2001-08-27 22:15:12 +0000383}
384
subrata_modak56207ce2009-03-23 13:35:39 +0000385int fill_mem(char *c_ptr, int c1, int c2)
plars865695b2001-08-27 22:15:12 +0000386{
387 int count;
388
389 for (count = 1; count <= K_1 / CHUNK; count++) {
subrata_modak56207ce2009-03-23 13:35:39 +0000390 if (count & 0x01) { /* if odd */
plars865695b2001-08-27 22:15:12 +0000391 memset(c_ptr, c1, CHUNK);
subrata_modak56207ce2009-03-23 13:35:39 +0000392 } else { /* if even */
plars865695b2001-08-27 22:15:12 +0000393 memset(c_ptr, c2, CHUNK);
394 }
395 }
subrata_modak43337a32009-02-26 11:43:51 +0000396 return 0;
plars865695b2001-08-27 22:15:12 +0000397}
398
subrata_modak56207ce2009-03-23 13:35:39 +0000399void sighandler(int sig)
plars865695b2001-08-27 22:15:12 +0000400{
401 switch (sig) {
subrata_modak56207ce2009-03-23 13:35:39 +0000402 case SIGTERM:
403 break;
plars865695b2001-08-27 22:15:12 +0000404
subrata_modak56207ce2009-03-23 13:35:39 +0000405 case SIGPIPE:
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800406 in_sighandler++;
subrata_modak56207ce2009-03-23 13:35:39 +0000407 return;
plars865695b2001-08-27 22:15:12 +0000408
subrata_modak56207ce2009-03-23 13:35:39 +0000409 default:
Garrett Cooper2aca6fc2010-12-19 03:12:40 -0800410 tst_resm(TFAIL, "sighandler received invalid signal:%d", sig);
subrata_modak56207ce2009-03-23 13:35:39 +0000411 break;
plars865695b2001-08-27 22:15:12 +0000412 }
Chris Dearmanec6edca2012-10-17 19:54:01 -0700413}