mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
use ps -f and awk to emulate pgrep
There is no pgrep in git for windows
This commit is contained in:
parent
98d0d8c642
commit
afce25cd65
|
|
@ -317,7 +317,20 @@ _exit() {
|
|||
stty sane; echo; echo "caught signal, shutting down"
|
||||
|
||||
IFS=$'\n'
|
||||
pid_list=( $(pgrep -P $$) )
|
||||
# The format of `ps` is different between Windows and other platforms,
|
||||
# so we need to calculate the total column number(COL_NUM) of header first.
|
||||
# Why don't we just use the last column?
|
||||
# Because the body of CMD column may contain space and be treated as multiple fileds.
|
||||
pid_list=( $(ps -f |
|
||||
awk -v ppid=$$ 'NR == 1 {
|
||||
COL_NUM = NF
|
||||
}
|
||||
$3 == ppid {
|
||||
# filter out temp processes created in this subshell
|
||||
if ($COL_NUM != "ps" && $COL_NUM != "awk" && $COL_NUM !~ "bash$")
|
||||
print $2
|
||||
}')
|
||||
)
|
||||
IFS="$defaultIFS"
|
||||
|
||||
local _pid
|
||||
|
|
|
|||
Loading…
Reference in a new issue