unix pipe in C

I currently stuck on a simple program that requires unix pipe. I'm have never programmed with unix pipe before, so if anyone can point me to the right different will be greatly appreciated!

I'm suppose to write a program that the parent spawns many child processes and each of the child process are trying to decrement the same variable. This can be easily done with pthreads, since variables are shared in threads but not processes. I'm required to use the unix pipe facility and pipes only, so pthreads, sockets, shared memory are out of the question.

Since I'm new to this unix pipe thing, I did some readings online. Most of the tutorials are only talking about one child process trying to communicate with one parent process using an one-way pipe. There aren't any examples that talks about multiple child processes communicating with the parent. Heck, all I need to know is how to make all these child processes access to the same variable and avoid race conditions.

I did thought about using a semaphore to do the locking and a file to store the variable, however I don't know where the pipe will come in in this approach (since I'm required need to use pipes to do the program).

Thanks in advance!

It seems you havn't read the rules. Classroom problems are not allowed.