Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [ $# -ne 1 ]; then
- echo "Usage: $0 <num_subscribers>"
- exit 1
- fi
- num_subscribers=$1
- # Compile the C programs
- gcc publisher.c -o publisher
- gcc subscriber.c -o subscriber
- # Run the publisher in the background
- ./publisher $num_subscribers &
- # Run the subscribers in separate terminal windows
- for ((i = 1; i <= num_subscribers; i++)); do
- x-terminal-emulator -e ./subscriber $i &
- done
- # Wait for all subscribers to finish
- wait
- # Clean up
- rm publisher subscriber
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement