Bash script kill background (grand)children on Ctrl+C

后端 未结 2 1100
暗喜
暗喜 2021-01-13 01:52

I have a Bash script (Bash 3.2, Mac OS X 10.8) that invokes multiple Python scripts in parallel in order to better utilize multiple cores. Each Python script takes a really

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-13 02:08

    Your trap looks good to me:

    $ bash --version
    GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin11)
    Copyright (C) 2007 Free Software Foundation, Inc.
    
    $ cat ./thang 
    #! /bin/bash
    set -e
    
    cat >work.py <

提交回复
热议问题