1 /* @(#)fpipe.c 1.12 04/08/08 Copyright 1986, 1995-2003 J. Schilling */ 2 /* 3 * Copyright (c) 1986, 1995-2003 J. Schilling 4 */ 5 /* 6 * The contents of this file are subject to the terms of the 7 * Common Development and Distribution License, Version 1.0 only 8 * (the "License"). You may not use this file except in compliance 9 * with the License. 10 * 11 * See the file CDDL.Schily.txt in this distribution for details. 12 * A copy of the CDDL is also available via the Internet at 13 * http://www.opensource.org/licenses/cddl1.txt 14 * 15 * When distributing Covered Code, include this CDDL HEADER in each 16 * file and include the License file CDDL.Schily.txt from this distribution. 17 */ 18 19 #include "schilyio.h" 20 21 EXPORT int fpipe(pipef)22fpipe(pipef) 23 FILE *pipef[]; 24 { 25 int filedes[2]; 26 27 if (pipe(filedes) < 0) 28 return (0); 29 30 if ((pipef[0] = _fcons((FILE *)0, 31 filedes[0], FI_READ|FI_CLOSE)) != (FILE *)0) { 32 if ((pipef[1] = _fcons((FILE *)0, 33 filedes[1], FI_WRITE|FI_CLOSE)) != (FILE *)0) { 34 return (1); 35 } 36 fclose(pipef[0]); 37 } 38 close(filedes[1]); 39 return (0); 40 } 41