I have an emacs shell buffer which may or may not be running a certain interactive program such as
python. I wish to write a lisp function which will interact with this program, but I would first like to make sure that said program is indeed running. My question is therefore:
Is there a Lisp function designed to inquire which program, if any, is running inside a given shell buffer?
Such programs often set their own prompt, so I thought of using
(buffer-substring (car comint-last-prompt) (cdr comint-last-prompt))
to determine the current prompt, but prompts often get garbled, so I found this not to be the ideal solution. Another attempt involved using
(shell-command-to-string "pgrep -fa MYPROGRAM")
but this would risk a false positive in case
MYPROGRAM is running somewhere else in the system, other than under my shell buffer.