annotate lisp/eshell/esh-proc.el @ 68919:82552609c524

(x_set_menu_bar_lines): Menu bar is always shown on Mac.
author YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
date Wed, 15 Feb 2006 08:41:36 +0000
parents 067115a6e738
children f7702c5f335d c5406394f567
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37658
diff changeset
1 ;;; esh-proc.el --- process management
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2
64701
34bd8e434dd7 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64085
diff changeset
3 ;; Copyright (C) 1999, 2000, 2002, 2003, 2004,
68648
067115a6e738 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 65596
diff changeset
4 ;; 2005, 2006 Free Software Foundation, Inc.
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5
32526
8e57189d61b4 Add author information.
Gerd Moellmann <gerd@gnu.org>
parents: 31241
diff changeset
6 ;; Author: John Wiegley <johnw@gnu.org>
8e57189d61b4 Add author information.
Gerd Moellmann <gerd@gnu.org>
parents: 31241
diff changeset
7
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 ;; any later version.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64085
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
23 ;; Boston, MA 02110-1301, USA.
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25 (provide 'esh-proc)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27 (eval-when-compile (require 'esh-maint))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 (defgroup eshell-proc nil
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30 "When Eshell invokes external commands, it always does so
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31 asynchronously, so that Emacs isn't tied up waiting for the process to
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32 finish."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33 :tag "Process management"
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
34 :group 'eshell)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
35
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36 ;;; Commentary:
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
37
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38 ;;; User Variables:
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40 (defcustom eshell-proc-load-hook '(eshell-proc-initialize)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41 "*A hook that gets run when `eshell-proc' is loaded."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 :type 'hook
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43 :group 'eshell-proc)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 (defcustom eshell-process-wait-seconds 0
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 "*The number of seconds to delay waiting for a synchronous process."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47 :type 'integer
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48 :group 'eshell-proc)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 (defcustom eshell-process-wait-milliseconds 50
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51 "*The number of milliseconds to delay waiting for a synchronous process."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52 :type 'integer
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 :group 'eshell-proc)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55 (defcustom eshell-done-messages-in-minibuffer t
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56 "*If non-nil, subjob \"Done\" messages will display in minibuffer."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57 :type 'boolean
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58 :group 'eshell-proc)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60 (defcustom eshell-delete-exited-processes t
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61 "*If nil, process entries will stick around until `jobs' is run.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62 This variable sets the buffer-local value of `delete-exited-processes'
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63 in Eshell buffers.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
64
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65 This variable causes Eshell to mimic the behavior of bash when set to
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
66 nil. It allows the user to view the exit status of a completed subjob
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67 \(process) at their leisure, because the process entry remains in
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68 memory until the user examines it using \\[list-processes].
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 Otherwise, if `eshell-done-messages-in-minibuffer' is nil, and this
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
71 variable is set to t, the only indication the user will have that a
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
72 subjob is done is that it will no longer appear in the
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73 \\[list-processes\\] display.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75 Note that Eshell will have to be restarted for a change in this
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 variable's value to take effect."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 :type 'boolean
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78 :group 'eshell-proc)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80 (defcustom eshell-reset-signals
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81 "^\\(interrupt\\|killed\\|quit\\|stopped\\)"
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 "*If a termination signal matches this regexp, the terminal will be reset."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83 :type 'regexp
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84 :group 'eshell-proc)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
86 (defcustom eshell-exec-hook nil
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87 "*Called each time a process is exec'd by `eshell-gather-process-output'.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88 It is passed one argument, which is the process that was just started.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
89 It is useful for things that must be done each time a process is
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
90 executed in a eshell mode buffer (e.g., `process-kill-without-query').
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91 In contrast, `eshell-mode-hook' is only executed once when the buffer
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92 is created."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
93 :type 'hook
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
94 :group 'eshell-proc)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
96 (defcustom eshell-kill-hook '(eshell-reset-after-proc)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97 "*Called when a process run by `eshell-gather-process-output' has ended.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98 It is passed two arguments: the process that was just ended, and the
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99 termination status (as a string). Note that the first argument may be
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100 nil, in which case the user attempted to send a signal, but there was
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
101 no relevant process. This can be used for displaying help
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
102 information, for example."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
103 :type 'hook
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 :group 'eshell-proc)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
106 ;;; Internal Variables:
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
108 (defvar eshell-current-subjob-p nil)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
109
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
110 (defvar eshell-process-list nil
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
111 "A list of the current status of subprocesses.")
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
112
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
113 ;;; Functions:
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
114
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
115 (defun eshell-proc-initialize ()
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
116 "Initialize the process handling code."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
117 (make-local-variable 'eshell-process-list)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
118 (define-key eshell-command-map [(meta ?i)] 'eshell-insert-process)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
119 (define-key eshell-command-map [(control ?c)] 'eshell-interrupt-process)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
120 (define-key eshell-command-map [(control ?k)] 'eshell-kill-process)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
121 (define-key eshell-command-map [(control ?d)] 'eshell-send-eof-to-process)
37658
f9277090a94a Disable `eshell-stop-process' and `eshell-continue-process', since
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
122 ; (define-key eshell-command-map [(control ?q)] 'eshell-continue-process)
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123 (define-key eshell-command-map [(control ?s)] 'list-processes)
37658
f9277090a94a Disable `eshell-stop-process' and `eshell-continue-process', since
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
124 ; (define-key eshell-command-map [(control ?z)] 'eshell-stop-process)
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125 (define-key eshell-command-map [(control ?\\)] 'eshell-quit-process))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127 (defun eshell-reset-after-proc (proc status)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128 "Reset the command input location after a process terminates.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129 The signals which will cause this to happen are matched by
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130 `eshell-reset-signals'."
31241
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
131 (if (and (stringp status)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
132 (string-match eshell-reset-signals status))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
133 (eshell-reset)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135 (defun eshell-wait-for-process (&rest procs)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136 "Wait until PROC has successfully completed."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 (while procs
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138 (let ((proc (car procs)))
31241
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
139 (when (eshell-processp proc)
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140 ;; NYI: If the process gets stopped here, that's bad.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141 (while (assq proc eshell-process-list)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142 (if (input-pending-p)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
143 (discard-input))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
144 (sit-for eshell-process-wait-seconds
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145 eshell-process-wait-milliseconds))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146 (setq procs (cdr procs))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148 (defalias 'eshell/wait 'eshell-wait-for-process)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150 (defun eshell/jobs (&rest args)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151 "List processes, if there are any."
31241
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
152 (and (fboundp 'process-list)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
153 (process-list)
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
154 (list-processes)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
155
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
156 (defun eshell/kill (&rest args)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
157 "Kill processes, buffers, symbol or files."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
158 (let ((ptr args)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
159 (signum 'SIGINT))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160 (while ptr
31241
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
161 (if (or (eshell-processp (car ptr))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
162 (and (stringp (car ptr))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
163 (string-match "^[A-Za-z/][A-Za-z0-9<>/]+$"
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
164 (car ptr))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
165 ;; What about when $lisp-variable is possible here?
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
166 ;; It could very well name a process.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
167 (setcar ptr (get-process (car ptr))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
168 (setq ptr (cdr ptr)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
169 (while args
31241
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
170 (let ((id (if (eshell-processp (car args))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
171 (process-id (car args))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
172 (car args))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
173 (when id
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174 (cond
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
175 ((null id)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
176 (error "kill: bad signal spec"))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
177 ((and (numberp id) (= id 0))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
178 (error "kill: bad signal spec `%d'" id))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
179 ((and (stringp id)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
180 (string-match "^-?[0-9]+$" id))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
181 (setq signum (abs (string-to-number id))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
182 ((stringp id)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
183 (let (case-fold-search)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
184 (if (string-match "^-\\([A-Z]+\\)$" id)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
185 (setq signum
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
186 (intern (concat "SIG" (match-string 1 id))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
187 (error "kill: bad signal spec `%s'" id))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
188 ((< id 0)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
189 (setq signum (abs id)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
190 (t
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
191 (signal-process id signum)))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
192 (setq args (cdr args)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
193 nil))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
194
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
195 (defun eshell-read-process-name (prompt)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
196 "Read the name of a process from the minibuffer, using completion.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
197 The prompt will be set to PROMPT."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
198 (completing-read prompt
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
199 (mapcar
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
200 (function
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
201 (lambda (proc)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
202 (cons (process-name proc) t)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
203 (process-list)) nil t))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
204
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
205 (defun eshell-insert-process (process)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
206 "Insert the name of PROCESS into the current buffer at point."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
207 (interactive
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
208 (list (get-process
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
209 (eshell-read-process-name "Name of process: "))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
210 (insert-and-inherit "#<process " (process-name process) ">"))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
211
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
212 (defsubst eshell-record-process-object (object)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
213 "Record OBJECT as now running."
31241
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
214 (if (and (eshell-processp object)
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
215 eshell-current-subjob-p)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
216 (eshell-interactive-print
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
217 (format "[%s] %d\n" (process-name object) (process-id object))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
218 (setq eshell-process-list
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
219 (cons (list object eshell-current-handles
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
220 eshell-current-subjob-p nil nil)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
221 eshell-process-list)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
222
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
223 (defun eshell-remove-process-entry (entry)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
224 "Record the process ENTRY as fully completed."
31241
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
225 (if (and (eshell-processp (car entry))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
226 (nth 2 entry)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
227 eshell-done-messages-in-minibuffer)
65596
e188ae94d98b Correct my previous breakage of parens.
Deepak Goel <deego@gnufans.org>
parents: 65588
diff changeset
228 (message "[%s]+ Done %s" (process-name (car entry))
e188ae94d98b Correct my previous breakage of parens.
Deepak Goel <deego@gnufans.org>
parents: 65588
diff changeset
229 (process-command (car entry))))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
230 (setq eshell-process-list
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
231 (delq entry eshell-process-list)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
232
31241
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
233 (defvar eshell-scratch-buffer " *eshell-scratch*"
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
234 "Scratch buffer for holding Eshell's input/output.")
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
235 (defvar eshell-last-sync-output-start nil
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
236 "A marker that tracks the beginning of output of the last subprocess.
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
237 Used only on systems which do not support async subprocesses.")
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
238
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
239 (defun eshell-gather-process-output (command args)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
240 "Gather the output from COMMAND + ARGS."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
241 (unless (and (file-executable-p command)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
242 (file-regular-p command))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
243 (error "%s: not an executable file" command))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
244 (let* ((delete-exited-processes
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
245 (if eshell-current-subjob-p
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
246 eshell-delete-exited-processes
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
247 delete-exited-processes))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
248 (process-environment (eshell-environment-variables))
31241
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
249 proc decoding encoding changed)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
250 (cond
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
251 ((fboundp 'start-process)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
252 (setq proc
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
253 (apply 'start-process
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
254 (file-name-nondirectory command) nil
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
255 ;; `start-process' can't deal with relative
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
256 ;; filenames
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
257 (append (list (expand-file-name command)) args)))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
258 (eshell-record-process-object proc)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
259 (set-process-buffer proc (current-buffer))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
260 (if (eshell-interactive-output-p)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
261 (set-process-filter proc 'eshell-output-filter)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
262 (set-process-filter proc 'eshell-insertion-filter))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
263 (set-process-sentinel proc 'eshell-sentinel)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
264 (run-hook-with-args 'eshell-exec-hook proc)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
265 (when (fboundp 'process-coding-system)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
266 (let ((coding-systems (process-coding-system proc)))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
267 (setq decoding (car coding-systems)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
268 encoding (cdr coding-systems)))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
269 ;; If start-process decided to use some coding system for
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
270 ;; decoding data sent from the process and the coding system
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
271 ;; doesn't specify EOL conversion, we had better convert CRLF
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
272 ;; to LF.
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
273 (if (vectorp (coding-system-eol-type decoding))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
274 (setq decoding (coding-system-change-eol-conversion decoding 'dos)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
275 changed t))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
276 ;; Even if start-process left the coding system for encoding
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
277 ;; data sent from the process undecided, we had better use the
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
278 ;; same one as what we use for decoding. But, we should
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
279 ;; suppress EOL conversion.
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
280 (if (and decoding (not encoding))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
281 (setq encoding (coding-system-change-eol-conversion decoding 'unix)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
282 changed t))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
283 (if changed
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
284 (set-process-coding-system proc decoding encoding))))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
285 (t
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
286 ;; No async subprocesses...
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
287 (let ((oldbuf (current-buffer))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
288 (interact-p (eshell-interactive-output-p))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
289 lbeg lend line proc-buf exit-status)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
290 (and (not (markerp eshell-last-sync-output-start))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
291 (setq eshell-last-sync-output-start (point-marker)))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
292 (setq proc-buf
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
293 (set-buffer (get-buffer-create eshell-scratch-buffer)))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
294 (erase-buffer)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
295 (set-buffer oldbuf)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
296 (run-hook-with-args 'eshell-exec-hook command)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
297 (setq exit-status
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
298 (apply 'call-process-region
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
299 (append (list eshell-last-sync-output-start (point)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
300 command t
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
301 eshell-scratch-buffer nil)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
302 args)))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
303 ;; When in a pipeline, record the place where the output of
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
304 ;; this process will begin.
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
305 (and eshell-in-pipeline-p
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
306 (set-marker eshell-last-sync-output-start (point)))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
307 ;; Simulate the effect of the process filter.
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
308 (when (numberp exit-status)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
309 (set-buffer proc-buf)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
310 (goto-char (point-min))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
311 (setq lbeg (point))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
312 (while (eq 0 (forward-line 1))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
313 (setq lend (point)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
314 line (buffer-substring-no-properties lbeg lend))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
315 (set-buffer oldbuf)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
316 (if interact-p
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
317 (eshell-output-filter nil line)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
318 (eshell-output-object line))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
319 (setq lbeg lend)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
320 (set-buffer proc-buf))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
321 (set-buffer oldbuf))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
322 (eshell-update-markers eshell-last-output-end)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
323 ;; Simulate the effect of eshell-sentinel.
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
324 (eshell-close-handles (if (numberp exit-status) exit-status -1))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
325 (run-hook-with-args 'eshell-kill-hook command exit-status)
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
326 (or eshell-in-pipeline-p
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
327 (setq eshell-last-sync-output-start nil))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
328 (if (not (numberp exit-status))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
329 (error "%s: external command failed: %s" command exit-status))
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
330 (setq proc t))))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
331 proc))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
332
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
333 (defun eshell-insertion-filter (proc string)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
334 "Insert a string into the eshell buffer, or a process/file/buffer.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
335 PROC is the process for which we're inserting output. STRING is the
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
336 output."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
337 (when (buffer-live-p (process-buffer proc))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
338 (set-buffer (process-buffer proc))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
339 (let ((entry (assq proc eshell-process-list)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
340 (when entry
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
341 (setcar (nthcdr 3 entry)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
342 (concat (nth 3 entry) string))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
343 (unless (nth 4 entry) ; already being handled?
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
344 (while (nth 3 entry)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
345 (let ((data (nth 3 entry)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
346 (setcar (nthcdr 3 entry) nil)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
347 (setcar (nthcdr 4 entry) t)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
348 (eshell-output-object data nil (cadr entry))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
349 (setcar (nthcdr 4 entry) nil))))))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
350
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
351 (defun eshell-sentinel (proc string)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
352 "Generic sentinel for command processes. Reports only signals.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
353 PROC is the process that's exiting. STRING is the exit message."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
354 (when (buffer-live-p (process-buffer proc))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
355 (set-buffer (process-buffer proc))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
356 (unwind-protect
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
357 (let* ((entry (assq proc eshell-process-list)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
358 ; (if (not entry)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
359 ; (error "Sentinel called for unowned process `%s'"
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
360 ; (process-name proc))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
361 (when entry
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
362 (unwind-protect
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
363 (progn
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
364 (unless (string= string "run")
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
365 (unless (string-match "^\\(finished\\|exited\\)" string)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
366 (eshell-insertion-filter proc string))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
367 (eshell-close-handles (process-exit-status proc) 'nil
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
368 (cadr entry))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
369 (eshell-remove-process-entry entry))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
370 (run-hook-with-args 'eshell-kill-hook proc string))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
371
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
372 (defun eshell-process-interact (func &optional all query)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
373 "Interact with a process, using PROMPT if more than one, via FUNC.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
374 If ALL is non-nil, background processes will be interacted with as well.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
375 If QUERY is non-nil, query the user with QUERY before calling FUNC."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
376 (let (defunct result)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
377 (eshell-for entry eshell-process-list
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
378 (if (and (memq (process-status (car entry))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
379 '(run stop open closed))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
380 (or all
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
381 (not (nth 2 entry)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
382 (or (not query)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
383 (y-or-n-p (format query (process-name (car entry))))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
384 (setq result (funcall func (car entry))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
385 (unless (memq (process-status (car entry))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
386 '(run stop open closed))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
387 (setq defunct (cons entry defunct))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
388 ;; clean up the process list; this can get dirty if an error
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
389 ;; occurred that brought the user into the debugger, and then they
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
390 ;; quit, so that the sentinel was never called.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
391 (eshell-for d defunct
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
392 (eshell-remove-process-entry d))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
393 result))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
394
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
395 (defcustom eshell-kill-process-wait-time 5
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
396 "*Seconds to wait between sending termination signals to a subprocess."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
397 :type 'integer
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
398 :group 'eshell-proc)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
399
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
400 (defcustom eshell-kill-process-signals '(SIGINT SIGQUIT SIGKILL)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
401 "*Signals used to kill processes when an Eshell buffer exits.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
402 Eshell calls each of these signals in order when an Eshell buffer is
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
403 killed; if the process is still alive afterwards, Eshell waits a
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
404 number of seconds defined by `eshell-kill-process-wait-time', and
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
405 tries the next signal in the list."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
406 :type '(repeat symbol)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
407 :group 'eshell-proc)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
408
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
409 (defcustom eshell-kill-processes-on-exit nil
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
410 "*If non-nil, kill active processes when exiting an Eshell buffer.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
411 Emacs will only kill processes owned by that Eshell buffer.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
412
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
413 If nil, ownership of background and foreground processes reverts to
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
414 Emacs itself, and will die only if the user exits Emacs, calls
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
415 `kill-process', or terminates the processes externally.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
416
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
417 If `ask', Emacs prompts the user before killing any processes.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
418
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
419 If `every', it prompts once for every process.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
420
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
421 If t, it kills all buffer-owned processes without asking.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
422
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
423 Processes are first sent SIGHUP, then SIGINT, then SIGQUIT, then
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
424 SIGKILL. The variable `eshell-kill-process-wait-time' specifies how
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
425 long to delay between signals."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
426 :type '(choice (const :tag "Kill all, don't ask" t)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
427 (const :tag "Ask before killing" ask)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
428 (const :tag "Ask for each process" every)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
429 (const :tag "Don't kill subprocesses" nil))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
430 :group 'eshell-proc)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
431
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
432 (defun eshell-round-robin-kill (&optional query)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
433 "Kill current process by trying various signals in sequence.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
434 See the variable `eshell-kill-processes-on-exit'."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
435 (let ((sigs eshell-kill-process-signals))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
436 (while sigs
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
437 (eshell-process-interact
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
438 (function
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
439 (lambda (proc)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
440 (signal-process (process-id proc) (car sigs)))) t query)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
441 (setq query nil)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
442 (if (not eshell-process-list)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
443 (setq sigs nil)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
444 (sleep-for eshell-kill-process-wait-time)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
445 (setq sigs (cdr sigs))))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
446
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
447 (defun eshell-query-kill-processes ()
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
448 "Kill processes belonging to the current Eshell buffer, possibly w/ query."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
449 (when (and eshell-kill-processes-on-exit
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
450 eshell-process-list)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
451 (save-window-excursion
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
452 (list-processes)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
453 (if (or (not (eq eshell-kill-processes-on-exit 'ask))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
454 (y-or-n-p (format "Kill processes owned by `%s'? "
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
455 (buffer-name))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
456 (eshell-round-robin-kill
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
457 (if (eq eshell-kill-processes-on-exit 'every)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
458 "Kill Eshell child process `%s'? ")))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
459 (let ((buf (get-buffer "*Process List*")))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
460 (if (and buf (buffer-live-p buf))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
461 (kill-buffer buf)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
462 (message nil))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
463
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
464 (custom-add-option 'eshell-exit-hook 'eshell-query-kill-processes)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
465
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
466 (defun eshell-interrupt-process ()
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
467 "Interrupt a process."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
468 (interactive)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
469 (unless (eshell-process-interact 'interrupt-process)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
470 (run-hook-with-args 'eshell-kill-hook nil "interrupt")))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
471
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
472 (defun eshell-kill-process ()
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
473 "Kill a process."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
474 (interactive)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
475 (unless (eshell-process-interact 'kill-process)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
476 (run-hook-with-args 'eshell-kill-hook nil "killed")))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
477
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
478 (defun eshell-quit-process ()
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
479 "Send quit signal to process."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
480 (interactive)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
481 (unless (eshell-process-interact 'quit-process)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
482 (run-hook-with-args 'eshell-kill-hook nil "quit")))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
483
37658
f9277090a94a Disable `eshell-stop-process' and `eshell-continue-process', since
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
484 ;(defun eshell-stop-process ()
f9277090a94a Disable `eshell-stop-process' and `eshell-continue-process', since
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
485 ; "Send STOP signal to process."
f9277090a94a Disable `eshell-stop-process' and `eshell-continue-process', since
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
486 ; (interactive)
f9277090a94a Disable `eshell-stop-process' and `eshell-continue-process', since
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
487 ; (unless (eshell-process-interact 'stop-process)
f9277090a94a Disable `eshell-stop-process' and `eshell-continue-process', since
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
488 ; (run-hook-with-args 'eshell-kill-hook nil "stopped")))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
489
37658
f9277090a94a Disable `eshell-stop-process' and `eshell-continue-process', since
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
490 ;(defun eshell-continue-process ()
f9277090a94a Disable `eshell-stop-process' and `eshell-continue-process', since
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
491 ; "Send CONTINUE signal to process."
f9277090a94a Disable `eshell-stop-process' and `eshell-continue-process', since
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
492 ; (interactive)
f9277090a94a Disable `eshell-stop-process' and `eshell-continue-process', since
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
493 ; (unless (eshell-process-interact 'continue-process)
f9277090a94a Disable `eshell-stop-process' and `eshell-continue-process', since
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
494 ; ;; jww (1999-09-17): this signal is not dealt with yet. For
f9277090a94a Disable `eshell-stop-process' and `eshell-continue-process', since
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
495 ; ;; example, `eshell-reset' will be called, and so will
f9277090a94a Disable `eshell-stop-process' and `eshell-continue-process', since
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
496 ; ;; `eshell-resume-eval'.
f9277090a94a Disable `eshell-stop-process' and `eshell-continue-process', since
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
497 ; (run-hook-with-args 'eshell-kill-hook nil "continue")))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
498
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
499 (defun eshell-send-eof-to-process ()
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
500 "Send EOF to process."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
501 (interactive)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
502 (eshell-send-input nil nil t)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
503 (eshell-process-interact 'process-send-eof))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
504
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
505 ;;; Code:
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
506
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 38414
diff changeset
507 ;;; arch-tag: ac477a3e-ee4d-4b44-8ec6-212010e607bb
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
508 ;;; esh-proc.el ends here