# file : libbutl/utility.bash.in # license : MIT; see accompanying LICENSE file if [ "$butl_utility" ]; then return 0 else butl_utility=true fi if (( BASH_VERSINFO[0] < 4 || BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] < 3 )); then echo 'error: bash 4.3 or later is required' 2>&1 exit 1 fi # Return the libbutl/ module directory. # # This is used to run the binding support executables. # function butl_path () { # BASH_SOURCE[0] contains the source path of the function being executed # (that is, us). # dirname "${BASH_SOURCE[0]}" } # Resume a stopped process execution by sending it the SIGCONT signal. # # Note that to avoid races the function waits until the process enters the # stopped state. # function butl_resume_process () # { local pid="$1" while true; do # Note that while the ps's -o option 'state' value is not specified by # POSIX, it is supported by all the major implementations with the leading # 'T' character indicating the 'stopped' process run state. # local s s="$(ps -p "$pid" -o state=)" if [ "${s:0:1}" == "T" ]; then kill -SIGCONT "$pid" break fi done }