Lots of errors.
char * myfifo = "/cygdrive/c/a/progsys/tmp";
I repeat: fifo's might not work on Windows, because windows doesn't even have them. The closest it has is a named pipe that doesn't actually exist as a file anywhere.
You don't actually quit after most errors.
fprintf(stderr,"#%s#\n",data);
Unless you really want to view everything as one giant messy line, you might want to put an \n in things once in a while.
if (pid == 0)
{
if(execl("b.exe","b.exe",NULL) == -1)
fprintf(stderr,"execl Error!\n");
exit(1);
Can't forget that. If b.exe fails to run for any reason, the child will keep going!
if (write(fd, data, strlen(buf))<0); perror("write() error");
That extra semicolon means it will always print 'write error', even when there's no write error.
printf("Parent ended ");
close(fd);
fd = open(myfifo, O_RDONLY);
Why is the parent opening the fifo twice? The child doesn't open it twice, the parent will wait forever for something to open it again.
Why do you have your child code in a separate program when you could put it all in one and save yourself a lot of headaches?
buf[numread]='0';
0 is not null, 0 is 0. Try '\0'.
write (1,buf,numread);
...not that you actually need a null terminator any more when you use write(). How about fprintf(stderr, "%d bytes\n", (int)numread); to see how many you actually read?
---------- Post updated at 09:29 AM ---------- Previous update was at 09:19 AM ----------
Lastly: Your main program is writing 0 bytes on purpose because you're checking the length of the wrong buffer -- buf, instead of data.
---------- Post updated at 09:33 AM ---------- Previous update was at 09:29 AM ----------
Also: sizeof(MAX_BUFFER) is probably 4 or 8, not 5000 like you intended. Just MAX_BUFFER is what you want.
---------- Post updated at 09:38 AM ---------- Previous update was at 09:33 AM ----------
Also if(fd = open(myfifo, O_WRONLY)<0)
doesn't have enough brackets. fd becomes either 0 or 1 -- which is never the FD of your open fifo! You've been reading from stdin and writing to stdin, not your fifo, I think.
When I correct all that, it works fine, with no sleep().