diff --git a/src/wg-quick/darwin.bash b/src/wg-quick/darwin.bash index c77441fa..1d56b1a5 100755 --- a/src/wg-quick/darwin.bash +++ b/src/wg-quick/darwin.bash @@ -85,13 +85,13 @@ parse_options() { } detect_launchd() { - unset LAUNCHED_BY_LAUNCHD - local line - while read -r line; do - if [[ $line =~ ^\s*domain\ =\ ]]; then - LAUNCHED_BY_LAUNCHD=1 - break - fi + LAUNCHED_BY_LAUNCHD=1 + local line + while read -r line; do + if [[ $line =~ ^\s*\(pid\ $$\ is\ not\ managed\ by\ launchd\) ]]; then + unset LAUNCHED_BY_LAUNCHD + break + fi done < <(launchctl procinfo $$ 2>/dev/null) }