#include #include #include #include #include #define BUFFER_SIZE 25 #define READ_END 0 #define WRITE_END 1 int main(int argc, char** argv) { //Create the read and write buffers char write_msg[BUFFER_SIZE]; if(argc == 2 && strlen(argv[1]) < BUFFER_SIZE) { strcpy(write_msg, argv[1]); } else { strcpy(write_msg, "Greetings"); } char read_msg[BUFFER_SIZE]; //set up the file desriptor array and create the pipe int fd[2]; if(pipe(fd) == -1) { std::cerr<<"Pipe Failed"< 0) { //This is the parent processes //Close the read end of the pipe close(fd[READ_END]); //Write the message to the pipe write(fd[WRITE_END], write_msg, strlen(write_msg)+1); //close the write end of the pipe close(fd[WRITE_END]); wait(NULL); std::cout<<"Child finished, parent exiting"<