xref: /original-bsd/usr.bin/learn/learn/makpipe.c (revision be7c7628)
1 /*-
2  * Copyright (c) 1986 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.proprietary.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)makpipe.c	4.5 (Berkeley) 04/17/91";
10 #endif /* not lint */
11 
12 #include "stdio.h"
13 #include "pathnames.h"
14 
15 makpipe()
16 {
17 	int f[2];
18 
19 	pipe(f);
20 	if (fork()==0) {
21 		close(f[1]);
22 		close(0);
23 		dup(f[0]);
24 		close(f[0]);
25 #if BSD4_2
26 		execl (_PATH_BSHELL, "sh", "-i", 0);
27 #else
28 		execlp(_PATH_CSHELL, "csh", "-if", 0);
29 #endif
30 		write(2, "Exec error\n", 11);
31 	}
32 	close(f[0]);
33 	sleep(2);	/* so shell won't eat up too much input */
34 	return(f[1]);
35 }
36