Created
September 26, 2012 01:40
-
-
Save ryo1kato/3785504 to your computer and use it in GitHub Desktop.
A wrapper to allow sudo chrt for synergys
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Give sudo right to run chrt for giving RT prio for synergys | |
# (relatively) safely to avoid delay of cursor or | |
# keyboard input in remote end. | |
# | |
# So far scheduler (SCHED_RR) and prio (50) is hard-coded. | |
synergys_exepath="/usr/bin/synergys" | |
targetpid="$1" | |
DIE () { | |
echo "ERROR: $*" >&2 | |
exit 1 | |
} | |
# Check if argument is numeric | |
if [ -z "$targetpid" -o -n "${targetpid//[0-9]/}" ] | |
then | |
DIE "Invalid PID number: $targetpid" | |
fi | |
if [ ! -d /proc/$targetpid ] | |
then | |
DIE "No process with PID=$targetpid running" | |
elif [ ! -r /proc/$targetpid/exe ] | |
then | |
DIE "You are not the owner of process PID=$targetpid" | |
elif [ "$(readlink /proc/$targetpid/exe)" != "$synergys_exepath" ] | |
then | |
DIE "The PID you gave ($targetpid) is not for synergys" | |
fi | |
echo sudo /usr/bin/chrt --rr -p 50 $targetpid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
USERNAME ALL=NOPASSWD:/usr/local/bin/chrt-synergys