Mercurial > emacs
comparison src/process.c @ 11144:c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
| author | Richard M. Stallman <rms@gnu.org> |
|---|---|
| date | Tue, 28 Mar 1995 17:34:52 +0000 |
| parents | 413d44c0bd41 |
| children | 117b32676686 |
comparison
equal
deleted
inserted
replaced
| 11143:a9a40def9903 | 11144:c2b689aeb934 |
|---|---|
| 2937 return process; | 2937 return process; |
| 2938 } | 2938 } |
| 2939 | 2939 |
| 2940 DEFUN ("signal-process", Fsignal_process, Ssignal_process, | 2940 DEFUN ("signal-process", Fsignal_process, Ssignal_process, |
| 2941 2, 2, "nProcess number: \nnSignal code: ", | 2941 2, 2, "nProcess number: \nnSignal code: ", |
| 2942 "Send the process with number PID the signal with code CODE.\n\ | 2942 "Send the process with process id PID the signal with code SIGCODE.\n\ |
| 2943 Both PID and CODE are integers.") | 2943 PID must be an integer. The process need not be a child of this Emacs.\n\ |
| 2944 (pid, sig) | 2944 SIGCODE may be an integer, or a symbol whose name is a signal name.") |
| 2945 Lisp_Object pid, sig; | 2945 (pid, sigcode) |
| 2946 Lisp_Object pid, sigcode; | |
| 2946 { | 2947 { |
| 2947 CHECK_NUMBER (pid, 0); | 2948 CHECK_NUMBER (pid, 0); |
| 2948 CHECK_NUMBER (sig, 1); | 2949 |
| 2950 #define handle_signal(NAME, VALUE) \ | |
| 2951 else if (!strcmp (name, NAME)) \ | |
| 2952 XSETINT (sigcode, VALUE) | |
| 2953 | |
| 2954 if (INTEGERP (sigcode)) | |
| 2955 ; | |
| 2956 else | |
| 2957 { | |
| 2958 unsigned char *name; | |
| 2959 | |
| 2960 CHECK_SYMBOL (sigcode, 1); | |
| 2961 name = XSYMBOL (sigcode)->name->data; | |
| 2962 | |
| 2963 if (0) | |
| 2964 ; | |
| 2965 #ifdef SIGHUP | |
| 2966 handle_signal ("SIGHUP", SIGHUP); | |
| 2967 #endif | |
| 2968 #ifdef SIGINT | |
| 2969 handle_signal ("SIGINT", SIGINT); | |
| 2970 #endif | |
| 2971 #ifdef SIGQUIT | |
| 2972 handle_signal ("SIGQUIT", SIGQUIT); | |
| 2973 #endif | |
| 2974 #ifdef SIGILL | |
| 2975 handle_signal ("SIGILL", SIGILL); | |
| 2976 #endif | |
| 2977 #ifdef SIGABRT | |
| 2978 handle_signal ("SIGABRT", SIGABRT); | |
| 2979 #endif | |
| 2980 #ifdef SIGEMT | |
| 2981 handle_signal ("SIGEMT", SIGEMT); | |
| 2982 #endif | |
| 2983 #ifdef SIGKILL | |
| 2984 handle_signal ("SIGKILL", SIGKILL); | |
| 2985 #endif | |
| 2986 #ifdef SIGFPE | |
| 2987 handle_signal ("SIGFPE", SIGFPE); | |
| 2988 #endif | |
| 2989 #ifdef SIGBUS | |
| 2990 handle_signal ("SIGBUS", SIGBUS); | |
| 2991 #endif | |
| 2992 #ifdef SIGSEGV | |
| 2993 handle_signal ("SIGSEGV", SIGSEGV); | |
| 2994 #endif | |
| 2995 #ifdef SIGSYS | |
| 2996 handle_signal ("SIGSYS", SIGSYS); | |
| 2997 #endif | |
| 2998 #ifdef SIGPIPE | |
| 2999 handle_signal ("SIGPIPE", SIGPIPE); | |
| 3000 #endif | |
| 3001 #ifdef SIGALRM | |
| 3002 handle_signal ("SIGALRM", SIGALRM); | |
| 3003 #endif | |
| 3004 #ifdef SIGTERM | |
| 3005 handle_signal ("SIGTERM", SIGTERM); | |
| 3006 #endif | |
| 3007 #ifdef SIGURG | |
| 3008 handle_signal ("SIGURG", SIGURG); | |
| 3009 #endif | |
| 3010 #ifdef SIGSTOP | |
| 3011 handle_signal ("SIGSTOP", SIGSTOP); | |
| 3012 #endif | |
| 3013 #ifdef SIGTSTP | |
| 3014 handle_signal ("SIGTSTP", SIGTSTP); | |
| 3015 #endif | |
| 3016 #ifdef SIGCONT | |
| 3017 handle_signal ("SIGCONT", SIGCONT); | |
| 3018 #endif | |
| 3019 #ifdef SIGCHLD | |
| 3020 handle_signal ("SIGCHLD", SIGCHLD); | |
| 3021 #endif | |
| 3022 #ifdef SIGTTIN | |
| 3023 handle_signal ("SIGTTIN", SIGTTIN); | |
| 3024 #endif | |
| 3025 #ifdef SIGTTOU | |
| 3026 handle_signal ("SIGTTOU", SIGTTOU); | |
| 3027 #endif | |
| 3028 #ifdef SIGIO | |
| 3029 handle_signal ("SIGIO", SIGIO); | |
| 3030 #endif | |
| 3031 #ifdef SIGXCPU | |
| 3032 handle_signal ("SIGXCPU", SIGXCPU); | |
| 3033 #endif | |
| 3034 #ifdef SIGXFSZ | |
| 3035 handle_signal ("SIGXFSZ", SIGXFSZ); | |
| 3036 #endif | |
| 3037 #ifdef SIGVTALRM | |
| 3038 handle_signal ("SIGVTALRM", SIGVTALRM); | |
| 3039 #endif | |
| 3040 #ifdef SIGPROF | |
| 3041 handle_signal ("SIGPROF", SIGPROF); | |
| 3042 #endif | |
| 3043 #ifdef SIGWINCH | |
| 3044 handle_signal ("SIGWINCH", SIGWINCH); | |
| 3045 #endif | |
| 3046 #ifdef SIGINFO | |
| 3047 handle_signal ("SIGINFO", SIGINFO); | |
| 3048 #endif | |
| 3049 #ifdef SIGUSR1 | |
| 3050 handle_signal ("SIGUSR1", SIGUSR1); | |
| 3051 #endif | |
| 3052 #ifdef SIGUSR2 | |
| 3053 handle_signal ("SIGUSR2", SIGUSR2); | |
| 3054 #endif | |
| 3055 else | |
| 3056 error ("Undefined signal name %s", XSTRING (sigcode)->data); | |
| 3057 } | |
| 3058 | |
| 3059 #undef handle_signal | |
| 3060 | |
| 2949 #ifdef WINDOWSNT | 3061 #ifdef WINDOWSNT |
| 2950 /* Only works for kill-type signals */ | 3062 /* Only works for kill-type signals */ |
| 2951 return make_number (win32_kill_process (XINT (pid), XINT (sig))); | 3063 return make_number (win32_kill_process (XINT (pid), XINT (sigcode))); |
| 2952 #else | 3064 #else |
| 2953 return make_number (kill (XINT (pid), XINT (sig))); | 3065 return make_number (kill (XINT (pid), XINT (sigcode))); |
| 2954 #endif | 3066 #endif |
| 2955 } | 3067 } |
| 2956 | 3068 |
| 2957 DEFUN ("process-send-eof", Fprocess_send_eof, Sprocess_send_eof, 0, 1, 0, | 3069 DEFUN ("process-send-eof", Fprocess_send_eof, Sprocess_send_eof, 0, 1, 0, |
| 2958 "Make PROCESS see end-of-file in its input.\n\ | 3070 "Make PROCESS see end-of-file in its input.\n\ |
