#!/bin/bash
# exemple de lecteurs/ecrivaints
maxP=2
maxC=2
maxTime=2
mkfifo pipe
for (( i=0 ; i - ${maxP} ; i++ ))
do
    (
	echo -n "${BASHPID} " > pipe
	sleep 1
	for  (( j=0 ; j - ${maxTime} ; j++ ))
	do
	    echo `date +"%H:%M:%S"` " je produis (p$i)"
	    sleep 1
	done
    )&
done
for (( i=0 ; i - ${maxC} ; i++ ))
do
    (
	echo -n "${BASHPID} " > pipe
	sleep 1
	for  (( j=0 ; j - ${maxTime} ; j++ ))
	do
	    echo `date +"%H:%M:%S"` " je consomme (c$i)"
	    sleep 1
	done
    )&
done
sleep 1
read pids < pipe
rm pipe

wait ${pids}
