Deleted Added
sdiff udiff text old ( 228975 ) new ( 250512 )
full compact
1/*
2 * $OpenBSD: dup2test.c,v 1.3 2003/07/31 21:48:08 deraadt Exp $
3 * $OpenBSD: dup2_self.c,v 1.3 2003/07/31 21:48:08 deraadt Exp $
4 * $OpenBSD: fcntl_dup.c,v 1.2 2003/07/31 21:48:08 deraadt Exp $
5 *
6 * Written by Artur Grabowski <art@openbsd.org> 2002 Public Domain.
7 *
8 * $FreeBSD: head/tools/regression/file/dup/dup.c 250512 2013-05-11 15:45:44Z jilles $
9 */
10
11/*
12 * Test #1: check if dup(2) works.
13 * Test #2: check if dup2(2) works.
14 * Test #3: check if dup2(2) returned a fd we asked for.
15 * Test #4: check if dup2(2) cleared close-on-exec flag for duped fd.
16 * Test #5: check if dup2(2) allows to dup fd to itself.

--- 122 unchanged lines hidden (view full) ---

139 /* Was close-on-exec cleared? */
140 ++test;
141 if (fcntl(fd2, F_GETFD) == 0)
142 printf("not ok %d - dup2(2) cleared close-on-exec\n", test);
143 else
144 printf("ok %d - dup2(2) didn't clear close-on-exec\n", test);
145
146 /* Does fcntl(F_DUPFD) work? */
147 if ((fd2 = fcntl(fd1, F_DUPFD, 10)) < 0)
148 err(1, "fcntl(F_DUPFD)");
149 if (fd2 < 10)
150 printf("not ok %d - fcntl(F_DUPFD) returned wrong fd %d\n",
151 ++test, fd2);
152 else
153 printf("ok %d - fcntl(F_DUPFD) works\n", ++test);
154
155 /* Was close-on-exec cleared? */
156 ++test;
157 if (fcntl(fd2, F_GETFD) != 0)
158 printf(
159 "not ok %d - fcntl(F_DUPFD) didn't clear close-on-exec\n",
160 test);
161 else

--- 72 unchanged lines hidden ---