genpipe.c: exclusive control by semaphore