trying to create fifo that can read and write. but some reason its not going below "O_RDONLY" line. any thoughts?

char *fifo_name = "fifo";
#define 0666
int main()
{
  int fd1;
  int fd2;  


  //create fifo
  if(mkfifo(fifo_name,FIFO_MODE) == -1)
  {
     exit(1);
  }
  //open fifo for read
  if((fd1 = open(fifo_name, O_RDONLY)) == -1)
  {
       exit(1);
  }
  //------------------------------------------------------------------------------ it doesnt come here
  //open fifo for write 
if((fd2 = open(fifo_name, O_WRONLY)) == -1) 
{ 
    exit(1); 
}
}

i cant use O_RDWR bc iam trying to create two fifos

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.