Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # a function to repeatedly print the content in "in.txt"
- function print_forever() {
- while [ 1 ];
- do
- cat "$1"
- sleep 1
- done
- }
- echo run the hello binary
- print_forever in.txt | ./hello &
- pid=$!
- echo "background process $pid started"
- trap_ctrlc() {
- echo -e "\n\ntrap_ctrlc\n\n"
- }
- trap trap_ctrlc INT
- # wait for all background processes to terminate
- wait
- echo first wait=$?
- kill $pid
- echo -e "\nkill=$? (0 = success)\n"
- wait $pid
- echo "wait=$? (the exit status from the background process)"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement