Next: , Previous: , Up: Processes   [Contents][Index]


57.7 Sending Signals to Processes

Sending a signal to a subprocess is a way of interrupting its activities. There are several different signals, each with its own meaning. The set of signals and their names is defined by the operating system. For example, the signal SIGINT means that the user has typed C-c, or that some analogous thing has happened.

Each signal has a standard effect on the subprocess. Most signals kill the subprocess, but some stop or resume execution instead. Most signals can optionally be handled by programs; if the program handles the signal, then we can say nothing in general about its effects.

The set of signals and their names is defined by the operating system; SXEmacs has facilities for sending only a few of the signals that are defined. SXEmacs can send signals only to its own subprocesses.

You can send signals explicitly by calling the functions in this section. SXEmacs also sends signals automatically at certain times: killing a buffer sends a SIGHUP signal to all its associated processes; killing SXEmacs sends a SIGHUP signal to all remaining processes. SIGHUP is a signal that indicates that the connection between the user and the process is broken, for example if a connection via a telephone line is hung up.

Each of the signal-sending functions takes two optional arguments: process and current-group.

The argument process must be either a process or a buffer, the name of one, or nil. If it is nil, the process defaults to the process associated with the current buffer. An error is signaled if process does not identify a process.

The argument current-group is a flag that makes a difference when you are running a job-control shell as an SXEmacs subprocess. If it is non-nil, then the signal is sent to the current foreground process group of the terminal that SXEmacs uses to communicate with the subprocess. If the process is a job-control shell, this means the shell’s current subjob. If it is nil, the signal is sent to the process group of the immediate subprocess of SXEmacs. If the subprocess is a job-control shell, this is the shell itself.

The flag current-group has no effect when a pipe is used to communicate with the subprocess, because the operating system does not support the distinction in the case of pipes. For the same reason, job-control shells won’t work when a pipe is used. See process-connection-type in Asynchronous Processes.

Some of the functions below take a signal argument, which identifies a signal to be sent. It must be either an integer or a symbol which names the signal, like SIGSEGV.

Function: process-send-signal signal &optional process current-group

This function sends the signal signal to the process process. The following functions can be implemented in terms of process-send-signal.

Function: interrupt-process &optional process current-group

This function interrupts the process process by sending the signal SIGINT. Outside of SXEmacs, typing the “interrupt character” (normally C-c) sends this signal. When the argument current-group is non-nil, you can think of this function as “typing C-c” on the terminal by which SXEmacs talks to the subprocess.

Function: kill-process &optional process current-group

This function kills the process process by sending the signal SIGKILL. This signal kills the subprocess immediately, and cannot be handled by the subprocess.

Function: quit-process &optional process current-group

This function sends the signal SIGQUIT to the process process. This signal is the one sent by the “quit character” (usually C-\) when you are not inside SXEmacs.

Function: stop-process &optional process current-group

This function stops the process process by sending the signal SIGTSTP. Use continue-process to resume its execution.

On systems with job control, the “stop character” (usually C-z) sends this signal (outside of SXEmacs). When current-group is non-nil, you can think of this function as “typing C-z” on the terminal SXEmacs uses to communicate with the subprocess.

Function: continue-process &optional process current-group

This function resumes execution of the process process by sending it the signal SIGCONT. This presumes that process was stopped previously.

Command: signal-process pid signal

This function sends a signal to the process with process id pid, which need not be a child of SXEmacs. The argument signal specifies which signal to send.


Next: , Previous: , Up: Processes   [Contents][Index]