Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [ $# -ne 1 ]; then
- echo "Usage: $0 <number of subscribers>"
- exit 1
- fi
- num_subscribers=$1
- # Create the directory for named pipes if it doesn't exist
- mkdir -p /tmp/ex1
- # Create named pipes for each subscriber
- for ((i=1; i<=$num_subscribers; i++)); do
- mkfifo /tmp/ex1/s$i
- done
- # Compile the C programs
- gcc publisher.c -o publisher
- gcc subscriber.c -o subscriber
- # Start the publisher
- ./publisher $num_subscribers &
- # Start the subscribers in separate terminal windows
- for ((i=1; i<=$num_subscribers; i++)); do
- gnome-terminal -- ./subscriber $i
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement