8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / refer / refer3.c
blob29b25aba57229239c50181802ad5e4f2e4ae261c
1 /*
2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
6 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
9 /*
10 * Copyright (c) 1980 Regents of the University of California.
11 * All rights reserved. The Berkeley software License Agreement
12 * specifies the terms and conditions for redistribution.
15 #pragma ident "%Z%%M% %I% %E% SMI"
17 #include "refer..c"
18 #define move(x, y) close(y); dup(x); close(x);
20 extern void err();
22 int
23 corout(char *in, char *out, char *rprog, char *arg, int outlen)
25 int pipev[2], fr1, fr2, fw1, fw2, n;
26 int status;
28 pipe(pipev);
29 fr1 = pipev[0];
30 fw1 = pipev[1];
31 pipe(pipev);
32 fr2 = pipev[0];
33 fw2 = pipev[1];
34 if (fork() == 0) {
35 close(fw1);
36 close(fr2);
37 move(fr1, 0);
38 move(fw2, 1);
39 execl(rprog, "deliv", arg, 0);
40 err("Can't run %s", rprog);
42 close(fw2);
43 close(fr1);
44 write(fw1, in, strlen(in));
45 close(fw1);
46 wait(&status);
47 n = read(fr2, out, outlen);
48 out[n] = 0;
49 close(fr2);
50 return (n);