send-signal-up-to-parent-SIGUSR1

# Parent sets up a trap for SIGUSR1
catching_at_parent(){
    echo.green "Caught at parent with PID: $$, BASHPID: $BASHPID"
}

trap catching_at_parent SIGUSR1

# Function to act as subshell, sending signal back to parent
subshell_function() {
    echo "Subshell running with PID: $$, BASHPID: $BASHPID"
    echo "Subshell sending SIGUSR1 to parent PID: $$"
    kill -SIGUSR1 $$ || echo "Failed to send signal"
}

# Simulate a process where the subshell is triggered via a pipe
echo "Parent waiting for signal with PID: $$"
echo "" |  subshell_function

# Keep the parent running for a bit to catch the signal
sleep 2