summaryrefslogtreecommitdiff
path: root/src/process.c
diff options
context:
space:
mode:
authorKim F. Storm <storm@cua.dk>2002-10-28 23:18:50 +0000
committerKim F. Storm <storm@cua.dk>2002-10-28 23:18:50 +0000
commitcdd5ea86dbc2ddc27094813503f00e8b13579dbb (patch)
tree7b9b21e0dcf8e765eddc8a0fa65e4cd5c8ff8e03 /src/process.c
parente8a3259964f68a6de15487e3f4dd1f223ca93613 (diff)
downloademacs-cdd5ea86dbc2ddc27094813503f00e8b13579dbb.tar.gz
(Fsignal_process): Allow PROCESS to be specified by
name in addition to pid (as integer or string).
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c44
1 files changed, 38 insertions, 6 deletions
diff --git a/src/process.c b/src/process.c
index 7af60a08742..c1379a923aa 100644
--- a/src/process.c
+++ b/src/process.c
@@ -5391,14 +5391,46 @@ If PROCESS is a network process, resume handling of incoming traffic. */)
}
DEFUN ("signal-process", Fsignal_process, Ssignal_process,
- 2, 2, "nProcess number: \nnSignal code: ",
- doc: /* Send the process with process id PID the signal with code SIGCODE.
-PID must be an integer. The process need not be a child of this Emacs.
+ 2, 2, "sProcess (name or number): \nnSignal code: ",
+ doc: /* Send PROCESS the signal with code SIGCODE.
+PROCESS may also be an integer specifying the process id of the
+process to signal; in this case, the process need not be a child of
+this Emacs.
SIGCODE may be an integer, or a symbol whose name is a signal name. */)
- (pid, sigcode)
- Lisp_Object pid, sigcode;
+ (process, sigcode)
+ Lisp_Object process, sigcode;
{
- CHECK_NUMBER (pid);
+ Lisp_Object pid;
+
+ if (INTEGERP (process))
+ {
+ pid = process;
+ goto got_it;
+ }
+
+ if (STRINGP (process))
+ {
+ Lisp_Object tem;
+ if (tem = Fget_process (process), NILP (tem))
+ {
+ pid = Fstring_to_number (process, make_number (10));
+ if (XINT (pid) != 0)
+ goto got_it;
+ }
+ process = tem;
+ }
+ else
+ process = get_process (process);
+
+ if (NILP (process))
+ return process;
+
+ CHECK_PROCESS (process);
+ pid = XPROCESS (process)->pid;
+ if (!INTEGERP (pid) || XINT (pid) <= 0)
+ error ("Cannot signal process %s", SDATA (XPROCESS (process)->name));
+
+ got_it:
#define handle_signal(NAME, VALUE) \
else if (!strcmp (name, NAME)) \