Pipes - Windows Anonymous Pipes Program Name PipeParent.c#include #include #include #define BUFFER_SIZE 25 int

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Windows Anonymous Pipes Program Name: PipeParent.c #include <stdio.h> #include <stdlib.h> #include <windows.h> #define BUFFER_SIZE 25 int main(VOID) { HANDLE ReadHandle, WriteHandle; STARTUPINFO si; PROCESS_INFORMATION pi; char message[BUFFER_SIZE] = "Greetings"; DWORD written; /* set up security attributes so that pipe handles are inherited */ SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL,TRUE}; /* allocate memory */ ZeroMemory(&pi, sizeof(pi)); /* create the pipe */ fprintf(stderr,"Create Pipe Failed\n"); return 1; } /* establish the START_INFO structure for the child process */ GetStartupInfo(&si); si.hStdError = GetStdHandle(STD_ERROR_HANDLE); si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE); /* redirect the standard input to the read end of the pipe */ si.hStdInput = ReadHandle; si.dwFlags = STARTF_USESTDHANDLES; /* we do not want the child to inherit the write end of the pipe */ SetHandleInformation( WriteHandle, HANDLE_FLAG_INHERIT, 0);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/01/2012 for the course CMP 426 taught by Professor Gwangs.jung during the Spring '12 term at CUNY Lehman.

Page1 / 4

Pipes - Windows Anonymous Pipes Program Name PipeParent.c#include #include #include #define BUFFER_SIZE 25 int

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online