The problem is in your line here:
while(fd2 = open(fifo, O_RDONLY)>=0){
Due to C operator precedence, this is really evaluated as:
while((fd2 = (open(fifo, O_RDONLY)>=0)) != 0){
I.e. call open()
, check if it's return value is greater than 0, then assign that boolean result to fd2
, then check if it is zero or not.
That way you are then reading from file no. 1, which is stdout and that surely blocks indefinitely.
Change it to this and everything starts working of course:
while((fd2 = open(fifo, O_RDONLY)) >=0){
Also you are opening the log file without any permissions, you should specify some so that you can access it afterwards somehow, e.g:
fd_log=open("/home/me/log.txt",O_WRONLY | O_CREAT | O_APPEND, 0600);