Skip to content

Instantly share code, notes, and snippets.

@sparr
Created September 9, 2024 21:25
Show Gist options
  • Select an option

  • Save sparr/498479a91a1a317a47b035e16f1c328c to your computer and use it in GitHub Desktop.

Select an option

Save sparr/498479a91a1a317a47b035e16f1c328c to your computer and use it in GitHub Desktop.

Revisions

  1. sparr created this gist Sep 9, 2024.
    16 changes: 16 additions & 0 deletions wait_for_one_process_to_exit.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    #!/bin/bash
    #
    # This script launches two processes and exits when either of them exits

    (
    do_thing_1
    kill -s SIGHUP $$
    ) &

    (
    do_thing_2
    kill -s SIGHUP $$
    ) &

    # wait for one of the processes to exit and send a SIGHUP back to this shell
    sleep infinity