Obsolete
/
libipc-old
Archived
3
0
Fork 0
This repository has been archived on 2024-06-18. You can view files and clone it, but cannot push or open issues/pull-requests.
libipc-old/pingpong/pingpong.sh

41 lines
750 B
Bash
Raw Normal View History

#!/bin/dash
REP=/tmp/ipc/
2016-06-05 20:48:13 +02:00
SERVICE="pongd"
NB=10
# CLEAN UP !
if [ $# -ne 0 ] && [ "$1" = clean ]
then
echo "clean rep ${REP}"
rm ${REP}/${SERVICE}
exit 0
fi
if [ $# -ne 0 ]
then
NB=$1
fi
for pid in `seq 1 ${NB}`
do
# we make the application pipes
2016-09-10 16:23:30 +02:00
mkfifo ${REP}${pid}-1-in 2>/dev/null
mkfifo ${REP}${pid}-1-out 2>/dev/null
# pid index version
2016-09-10 16:23:30 +02:00
echo "${pid} 1 5" > ${REP}${SERVICE}
# the purpose is to send something in the pipe
2016-09-10 16:23:30 +02:00
cat /dev/urandom | base64 | head -n 1 > ${REP}${pid}-1-out
# echo "hello world" > ${REP}${pid}-1-out
# the the service will answer with our message
echo "pid : ${pid}"
cat ${REP}/${pid}-1-in
done
echo "clean rep"
rm ${REP}/*-in
rm ${REP}/*-out