diff options
author | jpkotta <jpkotta@shannon> | 2012-04-10 19:03:24 -0500 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2017-01-28 20:49:24 -0700 |
commit | 04e303cb9fc7945219763859784fe03abe49ad29 (patch) | |
tree | 10484ee0244df7bf1eb4efa8e7c022746345a0f3 /openwith.el | |
parent | 0fe4e97e21d91f8c308a1bab89c3598e07d7b363 (diff) |
use nohup to start processes to disown them from emacs
the advantage is processes started this way will not close if emacs closes
Diffstat (limited to 'openwith.el')
-rw-r--r-- | openwith.el | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/openwith.el b/openwith.el index e3cf3d0..1478939 100644 --- a/openwith.el +++ b/openwith.el @@ -69,6 +69,22 @@ where the symbol 'file' is replaced by the file to be opened." :group 'openwith :type 'boolean) +(defun openwith-open (command arglist) + "Run external command COMMAND, in such a way that it is + disowned from the parent Emacs process. If Emacs dies, the + process spawned here lives on. ARGLIST is a list of strings, + each an argument to COMMAND." + (let ((shell-file-name "/bin/sh")) + (start-process-shell-command + "openwith-process" nil + (mapconcat 'identity + (concatenate 'list + '("nohup") + (list command) + (mapcar 'shell-quote-argument arglist) + '(">/dev/null")) + " ")))) + (defun openwith-file-handler (operation &rest args) "Open file with external program, if an association is configured." (when (and openwith-mode (not (buffer-modified-p)) (zerop (buffer-size))) @@ -86,7 +102,7 @@ where the symbol 'file' is replaced by the file to be opened." (when (or (not openwith-confirm-invocation) (y-or-n-p (format "%s %s? " (cadr oa) (mapconcat #'identity params " ")))) - (apply #'start-process "openwith-process" nil (cadr oa) params) + (openwith-open (cadr oa) params) (kill-buffer nil) ;; inhibit actions that would follow the regular ;; insertion of file contents |