john_
New Coder
I have written a program in c that firstly creates two processes with fork. The child process writes 2000 characters to a file and the parent process reads the characters from the file. The reading process is done with the use of threads. There are 4 threads and each one of them reads 500 characters. I have used a semaphore to wait for the child process to complete first. sem_post(&sem) at the end of child process and sem_wait(&sem) at the beginning of the parent process. But it doesn't work. The program gets into the child process and doesn't do anything. If I instead use waitpid the program runs fine. What do causes the problem?