diff options
author | Richard M. Stallman <rms@gnu.org> | 1995-03-28 17:34:52 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1995-03-28 17:34:52 +0000 |
commit | ead8cb52fba9a7406f686f217f54f4e582e17f74 (patch) | |
tree | e99e92a59c9c08fbb83d1caa315489853a839fc2 /src/process.c | |
parent | 42219750dbe362152756cd7e4b4e8b1a3c2f3a3b (diff) | |
download | emacs-ead8cb52fba9a7406f686f217f54f4e582e17f74.tar.gz |
(Fsignal_process): Allow signal names as well as numbers.
Diffstat (limited to 'src/process.c')
-rw-r--r-- | src/process.c | 126 |
1 files changed, 119 insertions, 7 deletions
diff --git a/src/process.c b/src/process.c index 1230887888f..e0c2bf1cff0 100644 --- a/src/process.c +++ b/src/process.c @@ -2939,18 +2939,130 @@ See function `interrupt-process' for more details on usage.") DEFUN ("signal-process", Fsignal_process, Ssignal_process, 2, 2, "nProcess number: \nnSignal code: ", - "Send the process with number PID the signal with code CODE.\n\ -Both PID and CODE are integers.") - (pid, sig) - Lisp_Object pid, sig; + "Send the process with process id PID the signal with code SIGCODE.\n\ +PID must be an integer. The process need not be a child of this Emacs.\n\ +SIGCODE may be an integer, or a symbol whose name is a signal name.") + (pid, sigcode) + Lisp_Object pid, sigcode; { CHECK_NUMBER (pid, 0); - CHECK_NUMBER (sig, 1); + +#define handle_signal(NAME, VALUE) \ + else if (!strcmp (name, NAME)) \ + XSETINT (sigcode, VALUE) + + if (INTEGERP (sigcode)) + ; + else + { + unsigned char *name; + + CHECK_SYMBOL (sigcode, 1); + name = XSYMBOL (sigcode)->name->data; + + if (0) + ; +#ifdef SIGHUP + handle_signal ("SIGHUP", SIGHUP); +#endif +#ifdef SIGINT + handle_signal ("SIGINT", SIGINT); +#endif +#ifdef SIGQUIT + handle_signal ("SIGQUIT", SIGQUIT); +#endif +#ifdef SIGILL + handle_signal ("SIGILL", SIGILL); +#endif +#ifdef SIGABRT + handle_signal ("SIGABRT", SIGABRT); +#endif +#ifdef SIGEMT + handle_signal ("SIGEMT", SIGEMT); +#endif +#ifdef SIGKILL + handle_signal ("SIGKILL", SIGKILL); +#endif +#ifdef SIGFPE + handle_signal ("SIGFPE", SIGFPE); +#endif +#ifdef SIGBUS + handle_signal ("SIGBUS", SIGBUS); +#endif +#ifdef SIGSEGV + handle_signal ("SIGSEGV", SIGSEGV); +#endif +#ifdef SIGSYS + handle_signal ("SIGSYS", SIGSYS); +#endif +#ifdef SIGPIPE + handle_signal ("SIGPIPE", SIGPIPE); +#endif +#ifdef SIGALRM + handle_signal ("SIGALRM", SIGALRM); +#endif +#ifdef SIGTERM + handle_signal ("SIGTERM", SIGTERM); +#endif +#ifdef SIGURG + handle_signal ("SIGURG", SIGURG); +#endif +#ifdef SIGSTOP + handle_signal ("SIGSTOP", SIGSTOP); +#endif +#ifdef SIGTSTP + handle_signal ("SIGTSTP", SIGTSTP); +#endif +#ifdef SIGCONT + handle_signal ("SIGCONT", SIGCONT); +#endif +#ifdef SIGCHLD + handle_signal ("SIGCHLD", SIGCHLD); +#endif +#ifdef SIGTTIN + handle_signal ("SIGTTIN", SIGTTIN); +#endif +#ifdef SIGTTOU + handle_signal ("SIGTTOU", SIGTTOU); +#endif +#ifdef SIGIO + handle_signal ("SIGIO", SIGIO); +#endif +#ifdef SIGXCPU + handle_signal ("SIGXCPU", SIGXCPU); +#endif +#ifdef SIGXFSZ + handle_signal ("SIGXFSZ", SIGXFSZ); +#endif +#ifdef SIGVTALRM + handle_signal ("SIGVTALRM", SIGVTALRM); +#endif +#ifdef SIGPROF + handle_signal ("SIGPROF", SIGPROF); +#endif +#ifdef SIGWINCH + handle_signal ("SIGWINCH", SIGWINCH); +#endif +#ifdef SIGINFO + handle_signal ("SIGINFO", SIGINFO); +#endif +#ifdef SIGUSR1 + handle_signal ("SIGUSR1", SIGUSR1); +#endif +#ifdef SIGUSR2 + handle_signal ("SIGUSR2", SIGUSR2); +#endif + else + error ("Undefined signal name %s", XSTRING (sigcode)->data); + } + +#undef handle_signal + #ifdef WINDOWSNT /* Only works for kill-type signals */ - return make_number (win32_kill_process (XINT (pid), XINT (sig))); + return make_number (win32_kill_process (XINT (pid), XINT (sigcode))); #else - return make_number (kill (XINT (pid), XINT (sig))); + return make_number (kill (XINT (pid), XINT (sigcode))); #endif } |