ppipe.cxx (813B)
1 /* 2 * 3 * C++ Portable Types Library (PTypes) 4 * Version 2.1.1 Released 27-Jun-2007 5 * 6 * Copyright (C) 2001-2007 Hovik Melikyan 7 * 8 * http://www.melikyan.com/ptypes/ 9 * 10 */ 11 12 #ifdef WIN32 13 # include <windows.h> 14 #else 15 # include <unistd.h> 16 #endif 17 18 #include "pstreams.h" 19 20 21 namespace ptypes { 22 23 24 void infile::pipe(outfile& out) 25 { 26 #ifdef WIN32 27 28 SECURITY_ATTRIBUTES sa; 29 HANDLE h[2]; 30 31 sa.nLength = sizeof(SECURITY_ATTRIBUTES); 32 sa.bInheritHandle = TRUE; 33 sa.lpSecurityDescriptor = NULL; 34 35 if (!CreatePipe(&h[0], &h[1], &sa, 0)) 36 #else 37 int h[2]; 38 if (::pipe(h) != 0) 39 #endif 40 error(uerrno(), "Couldn't create a local pipe"); 41 42 set_syshandle(int(h[0])); 43 peerhandle = int(h[1]); 44 out.set_syshandle(int(h[1])); 45 out.peerhandle = int(h[0]); 46 open(); 47 out.open(); 48 } 49 50 51 }