From 8669361595b5c2270a0f664c4cdc3d0e3700117f Mon Sep 17 00:00:00 2001 From: Narvin Singh Date: Sat, 2 Jan 2021 00:03:01 -0500 Subject: [PATCH] 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. --- avdd | 16 +++++++++------- avds | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/avdd b/avdd index 95a15b6..dd26224 100755 --- a/avdd +++ b/avdd @@ -44,9 +44,16 @@ DEFAULT_SEP_L='| ' DEFAULT_SEP_R=' ' DEFAULT_SUF=' ' MOD_DIR="$(dirname "$0")"/mod -FIFO=/tmp/avdd-fifo +FIFO=/tmp/avdd-fifo-"$("$(dirname "$0")"/rpid $$)" 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}}" sep_l="${3-${DEFAULT_SEP_L}}" sep_r="${4-${DEFAULT_SEP_R}}" @@ -57,12 +64,6 @@ mod_to_fn() { 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, # add its name to the ordered array, and call its function and cache the value declare -A stat_cache @@ -111,6 +112,7 @@ process_cmd () { # Setup the named pipe to receive commands if [[ ! -p "${FIFO}" ]]; then mkfifo "${FIFO}"; fi +# shellcheck disable=SC2064 trap "rm -f ${FIFO}" EXIT # Each time the pipe is emptied out, the inner while loop will finish, so diff --git a/avds b/avds index 0685a4f..eebea7b 100755 --- a/avds +++ b/avds @@ -44,7 +44,7 @@ EXAMPLES: avds 'bat,dt' m true " DAEMON=avdd -FIFO=/tmp/"${DAEMON}"-fifo +FIFO=/tmp/"${DAEMON}"-fifo-"$("$(dirname "$0")"/rpid $$)" # Convert integer milliseconds to floating point seconds ms_to_s () {