Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make stumpish work on OpenBSD again #298

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 25 additions & 18 deletions util/stumpish/stumpish
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,32 @@ fi

stumpwm_pid ()
{
local pid=$$
if command -v pgrep 2>&1 >/dev/null; then
STUMPWM_PID=$(pgrep -u $(id -u) stumpwm)
elif [ -d /proc ]; then
# Go up the process chain until we locate StumpWM's process using
# the /proc virtual file system.

local pid=$$

while [ $pid -ne 1 ]
do
if [ "$(cat /proc/${pid}/comm)" = "stumpwm" ]; then
STUMPWM_PID=$pid
break
else
pid=$(cut -f 4 -d " " < /proc/$pid/stat)
fi
done
fi

while :
do
if [ $pid -eq 1 ]
then
echo "StumpWM not found in the process tree, are you sure a graphical " 1>&2
echo "session is running and StumpWM is your WM? If you think this is " 1>&2
echo "a bug in stumpish, please report it." 1>&2
echo 1>&2
exit 1
elif [ "$(cat /proc/${pid}/comm)" = "stumpwm" ]
then
STUMPWM_PID=$pid
break
else
pid=$(cut -f 4 -d " " < /proc/$pid/stat)
fi
done
if [ -z "$STUMPWM_PID" ]; then
echo "StumpWM not found in the process tree, are you sure a graphical " 1>&2
echo "session is running and StumpWM is your WM? If you think this is " 1>&2
echo "a bug in stumpish, please report it." 1>&2
echo 1>&2
exit 1
fi
}

wait_result ()
Expand Down