1 /*	$OpenBSD: dup2.c,v 1.1.1.1 2018/04/10 23:00:53 bluhm Exp $	*/
2 /*
3  * Copyright (c) 2018 Alexander Bluhm <bluhm@openbsd.org>
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 #include <err.h>
19 #include <unistd.h>
20 
21 #include "header.h"
22 
23 void
24 fdops(int fdpre, int fdpost)
25 {
26 	if (dup2(fdpre, 5) == -1)
27 		err(1, "dup2 pre");
28 	if (dup2(fdpost, 6) == -1)
29 		err(1, "dup2 post");
30 	if (dup2(fdpre, 7) == -1)
31 		err(1, "dup2 pepare post overwite");
32 	if (dup2(fdpost, 7) == -1)
33 		err(1, "dup2 post overwrite");
34 	if (dup2(fdpost, 8) == -1)
35 		err(1, "dup2 pepare pre overwrite");
36 	if (dup2(fdpre, 8) == -1)
37 		err(1, "dup2 pre overwite");
38 	if (dup2(fdpre, 9) == -1)
39 		err(1, "dup2 pepare pre equal");
40 	if (dup2(9, 9) == -1)
41 		err(1, "dup2 pre equal");
42 	if (dup2(fdpost, 10) == -1)
43 		err(1, "dup2 pepare post equal");
44 	if (dup2(10, 10) == -1)
45 		err(1, "dup2 post equal");
46 }
47