* Re: have emacs use SIGTERM to end a process instead of SIGHUP
[not found] <mailman.586.1373322303.12400.help-gnu-emacs@gnu.org>
@ 2013-07-09 15:19 ` Barry Margolin
2013-07-12 11:03 ` John Leach
0 siblings, 1 reply; 6+ messages in thread
From: Barry Margolin @ 2013-07-09 15:19 UTC (permalink / raw)
To: help-gnu-emacs
In article <mailman.586.1373322303.12400.help-gnu-emacs@gnu.org>,
John Leach <john@johnleach.co.uk> wrote:
> Hi,
>
> 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.
That's really strange behavior for a non-daemon process. Wouldn't it
have the same problem if you ran it from a normal terminal and
disconnected?
SIGHUP is the expected signal when a process's terminal goes away.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: have emacs use SIGTERM to end a process instead of SIGHUP
2013-07-09 15:19 ` have emacs use SIGTERM to end a process instead of SIGHUP Barry Margolin
@ 2013-07-12 11:03 ` John Leach
0 siblings, 0 replies; 6+ messages in thread
From: John Leach @ 2013-07-12 11:03 UTC (permalink / raw)
To: help-gnu-emacs
On 09/07/13 16:19, Barry Margolin wrote:
> In article <mailman.586.1373322303.12400.help-gnu-emacs@gnu.org>,
> John Leach <john@johnleach.co.uk> wrote:
>
>> Hi,
>>
>> 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.
>
> That's really strange behavior for a non-daemon process. Wouldn't it
> have the same problem if you ran it from a normal terminal and
> disconnected?
>
> SIGHUP is the expected signal when a process's terminal goes away.
>
true - it's probably a good idea for me to submit a patch to this
program to have it behave properly.
John.
^ permalink raw reply [flat|nested] 6+ messages in thread
* have emacs use SIGTERM to end a process instead of SIGHUP
@ 2013-07-08 22:16 John Leach
2013-07-09 12:02 ` Tassilo Horn
0 siblings, 1 reply; 6+ messages in thread
From: John Leach @ 2013-07-08 22:16 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
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.
How can I have emacs send a SIGTERM instead of a SIGHUP to the processes
it manages?
fyi, I define a function to start the process like this:
> (defun nanoc-server ()
> "Runs a nanoc web server"
> (interactive)
> (let ((default-directory (repository-root)))
> (let ((process-connection-type t))
> (start-process-shell-command "nanoc-server" "nanoc-server" "bundle exec nanoc view -p 3005 -C")
> )))
Thanks in advance for any help,
John.
--
http://johnleach.co.uk
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: have emacs use SIGTERM to end a process instead of SIGHUP
2013-07-08 22:16 John Leach
@ 2013-07-09 12:02 ` Tassilo Horn
2013-07-12 11:01 ` John Leach
0 siblings, 1 reply; 6+ messages in thread
From: Tassilo Horn @ 2013-07-09 12:02 UTC (permalink / raw)
To: help-gnu-emacs
John Leach <john@johnleach.co.uk> writes:
Hi John,
> 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.
Bye,
Tassilo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: have emacs use SIGTERM to end a process instead of SIGHUP
2013-07-09 12:02 ` Tassilo Horn
@ 2013-07-12 11:01 ` John Leach
2013-07-15 10:46 ` Tassilo Horn
0 siblings, 1 reply; 6+ messages in thread
From: John Leach @ 2013-07-12 11:01 UTC (permalink / raw)
To: help-gnu-emacs
On 09/07/13 13:02, Tassilo Horn wrote:
> John Leach <john@johnleach.co.uk> writes:
>
> Hi John,
>
>> 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? Rather
than looking at the command line or something.
I'm lost with even the basic syntax to do any of this though. Could you
help?
Thanks,
John.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: have emacs use SIGTERM to end a process instead of SIGHUP
2013-07-12 11:01 ` John Leach
@ 2013-07-15 10:46 ` Tassilo Horn
0 siblings, 0 replies; 6+ messages in thread
From: Tassilo Horn @ 2013-07-15 10:46 UTC (permalink / raw)
To: help-gnu-emacs
John Leach <john@johnleach.co.uk> 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"
(interactive)
(let ((default-directory (repository-root))
(process-connection-type t))
(setq nanoc-process
(start-process-shell-command
"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.
Bye,
Tassilo
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-07-15 10:46 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.586.1373322303.12400.help-gnu-emacs@gnu.org>
2013-07-09 15:19 ` have emacs use SIGTERM to end a process instead of SIGHUP Barry Margolin
2013-07-12 11:03 ` John Leach
2013-07-08 22:16 John Leach
2013-07-09 12:02 ` Tassilo Horn
2013-07-12 11:01 ` John Leach
2013-07-15 10:46 ` Tassilo Horn
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.