I'm compiling a latex file in a script and then I'm trying to either open a new pdf reader window or reload the current one (llpp being my reader), so after compiling my script does
pdflatex $FILE_NAME LLPP_ID=$(pgrep llpp) if [ $LLPP_ID ] then kill -HUP $LLPP_ID else llpp $FILE_PATH"/"$FILE_NAME".pdf" & fi
which works as intended as long as there is only one llpp window open. I would like to fix this to work for any number of llpp windows open.
Ideally I would fix the PID of the process from the bash script, but I understand this is not possible as PID are assigned by the kernel.
I thought I could use environment variable, but than they would remain available for subshells, but then I could run in a situation where I compile the file, store the PID into a env variable, close the terminal and lose the env variable while the LLPP windows remains open but I don't know where to look for it's PID anymore.
How could I do this?