/* * fifoWrite.c++ shows that the process is blocked on open * as there is no writing process * $ mkfifo -m 0666 myFIFO * $ g++ -Wall fifoRead.c++ -o fifoRead * $ g++ -Wall fifoWrite.c++ -o fifoWrite * $ ./fifoWrite myFIFO & * $ ./fifoRead myFIFO & */ #include using namespace std; #include #include #include #include #include #include #include #include #define MAX 100 // $ mkfifo -m 0666 myFIFO // $ g++ -Wall fifoRead.c++ -o fifoRead // $ g++ -Wall fifoWrite.c++ -o fifoWrite // $ ./fifoWrite myFIFO & // $ ./fifoRead myFIFO & int main(int ac, char *av[]) { int pd; char buff[MAX]="IIT Kalyani"; if(ac < 2){ cerr << "FIFO name not specified\n"; exit(1); } pd = open(av[1], O_WRONLY); if(pd == -1){ cerr << "FIFO open error\n"; exit(1); } cout << "Not be printed until fifoRead\n"; write(pd, buff, strlen(buff)); close(pd); return 0; }