bash process synching
The snippet can be accessed without any authentication.
Authored by
cyberta
Proof of Concept to showcase that https://0xacab.org/leap/obfsvpn/-/merge_requests/29 correctly handles the obfsvpn server and control plane shutdown once either of both processes finish
test2.sh 49 B
test3.sh 73 B
test_sync_2_background_processes.sh 231 B
test_synch_fg_and_bg_process 439 B
#!/bin/bash
set -e
kill_foreground() {
echo "Background script has finished. Killing foreground script."
ps -C "test3.sh" -o "%p"| grep -v PID | xargs kill;
}
kill_background() {
echo "Foreground script finished. Killing background script."
kill 0;
}
trap "exit" INT TERM
trap "kill_background" EXIT
./test2.sh &
export PID1=$!
( tail -f --pid=$PID1 /dev/null; echo "kill test3.sh "; kill_foreground ) &
./test3.sh
Please register or sign in to comment