I am writing a lisp program to be run as a batch file through emacs.
The program calls an external application which is supposed to stay running after the call to emacs finishes.
The two basic ways for emacs to call external application that I am
aware of are call-process
and start-process
.
Since call-process
creates a synchronous process, it does not meet my requirement to stay alive after
the call to emacs is done, so I believe my only alternative is start-process
.
However, even though start-process
is supposed to create asynchronous processes, it seems like the
created process is killed when emacs finishes.
Question. How to start a persistent asynchronous process trough batch in emacs, i.e, one that neither waits for, nor gets killed when emacs finishes?
In the examples below I am using, as external application, the pdf viewer Okular, but you might substitute it for any other GUI application.
;; Does not work because emacs waits for call-process to finish.
SHELL-PROMPT> emacs -Q --batch --eval '(call-process "okular" nil nil nil)'
;; Does not work because emacs apparently kills the created process upon exit
SHELL-PROMPT> emacs -Q --batch --eval '(start-process "Okular" nil "okular")'
;; Here is some more evidence that emacs kills the created process upon exit
SHELL-PROMPT> emacs -Q --batch --eval '(progn (start-process "Okular" nil "okular") (sit-for 3))'