[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: have emacs use SIGTERM to end a process instead of SIGHUP

From: Tassilo Horn
Subject: Re: have emacs use SIGTERM to end a process instead of SIGHUP
Date: Mon, 15 Jul 2013 12:46:37 +0200
User-agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.50 (gnu/linux)

John Leach <> writes:

>>> I'm starting a process using start-process-shell-command, but the
>>> command I'm running doesn't exit when it receives a SIGHUP (it
>>> reloads it's configs or something) so I end up with orphaned
>>> processes hanging around when I close the buffer or exit emacs.
>> I guess you could add a function to `kill-buffer-hook' that calls
>> `delete-process' on the process.
> thanks Tassilo. I'm trying to do this but failing.
> So I think I need a kill-buffer-hook that can get the process of the
> current buffer, check if it looks like the process I know needs a
> SIGTERM, and then send it one.
> I'm wondering if I can set some kind of attribute on the buffer when I
> create the process, so I can easily recognise it at kill time?

You could use a buffer-local variable.  E.g.

--8<---------------cut here---------------start------------->8---
(defvar nanoc-process nil)
(make-variable-buffer-local 'nanoc-process)

(defun nanoc-kill-process ()
  (when nanoc-process
    (delete-process nanoc-process)))

(defun nanoc-server ()
  "Runs a nanoc web server"
  (let ((default-directory (repository-root))
        (process-connection-type t))
    (setq nanoc-process
           "nanoc-server" "nanoc-server"
           "bundle exec nanoc view -p 3005 -C"))
    (add-hook 'kill-buffer-hook #'nanoc-kill-process nil t)))
--8<---------------cut here---------------end--------------->8---

Then every buffer may have its own nanoc-server process, and when
killing the buffer only that buffer's process is deleted.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]