Fix: Unique fifo per session

Use rpid in the daemon and the scheduler to append the PID of their
common login process to the named pipe so daemons and schedulers in
other sessions won't conflict with one another.
This commit is contained in:
Narvin Singh 2021-01-02 00:03:01 -05:00
parent 3b675b0da0
commit 8669361595
2 changed files with 10 additions and 8 deletions

16
avdd
View File

@ -44,9 +44,16 @@ DEFAULT_SEP_L='| '
DEFAULT_SEP_R=' ' DEFAULT_SEP_R=' '
DEFAULT_SUF=' ' DEFAULT_SUF=' '
MOD_DIR="$(dirname "$0")"/mod MOD_DIR="$(dirname "$0")"/mod
FIFO=/tmp/avdd-fifo FIFO=/tmp/avdd-fifo-"$("$(dirname "$0")"/rpid $$)"
mod_list="${1-${DEFAULT_MOD_LIST}}" mod_list="${1-${DEFAULT_MOD_LIST}}"
# Check if the user needs help
if [[ "${mod_list}" =~ ^(-h|-(-)?help)$ ]]; then
printf '%s' "${USAGE}" 1>&2
exit 0
fi
pre="${2-${DEFAULT_PRE}}" pre="${2-${DEFAULT_PRE}}"
sep_l="${3-${DEFAULT_SEP_L}}" sep_l="${3-${DEFAULT_SEP_L}}"
sep_r="${4-${DEFAULT_SEP_R}}" sep_r="${4-${DEFAULT_SEP_R}}"
@ -57,12 +64,6 @@ mod_to_fn() {
printf 'mod_%s' "${1//-/_}" printf 'mod_%s' "${1//-/_}"
} }
# Check if the user needs help
if [[ "${mod_list}" =~ ^(-h|-(-)?help)$ ]]; then
printf '%s' "${USAGE}" 1>&2
exit 0
fi
# For each module in the list, if the module file exists then source it, # For each module in the list, if the module file exists then source it,
# add its name to the ordered array, and call its function and cache the value # add its name to the ordered array, and call its function and cache the value
declare -A stat_cache declare -A stat_cache
@ -111,6 +112,7 @@ process_cmd () {
# Setup the named pipe to receive commands # Setup the named pipe to receive commands
if [[ ! -p "${FIFO}" ]]; then mkfifo "${FIFO}"; fi if [[ ! -p "${FIFO}" ]]; then mkfifo "${FIFO}"; fi
# shellcheck disable=SC2064
trap "rm -f ${FIFO}" EXIT trap "rm -f ${FIFO}" EXIT
# Each time the pipe is emptied out, the inner while loop will finish, so # Each time the pipe is emptied out, the inner while loop will finish, so

2
avds
View File

@ -44,7 +44,7 @@ EXAMPLES:
avds 'bat,dt' m true avds 'bat,dt' m true
" "
DAEMON=avdd DAEMON=avdd
FIFO=/tmp/"${DAEMON}"-fifo FIFO=/tmp/"${DAEMON}"-fifo-"$("$(dirname "$0")"/rpid $$)"
# Convert integer milliseconds to floating point seconds # Convert integer milliseconds to floating point seconds
ms_to_s () { ms_to_s () {