kill

Command Function

This command is used to send a specific signal to a specified process.

Syntax

kill [signo | -signo] [pid]

Parameters

Table 1 Parameter description

Parameter

Description

Value Range

signo

Specifies the signal ID.

[1,30]

pid

Specifies the process ID.

[1,MAX_INT]

NOTICE: The valid range of the signo value is [0, 64], and the recommended value range is [1, 30]. Other values in the valid range are reserved.

Usage

The signo and pid parameters are mandatory.

The pid value range varies depending on the system configuration. For example, if the maximum pid value supported by the system is 256, this value range is [1-256].

Example

  1. Query the process list and determine the PID (7) of the process to be killed.

Figure 1 Querying PIDs

  1. Run kill 14 7 to send signal 14 (the default behavior of SIGALRM is to terminate the process) to process 7 helloworld_d (user-space). Then query the current process list. Process 7 has been terminated. The result of the kill 14 7 command is the same as that of the kill -14 7 command.

Figure 2 Command output

Output

The command output is as follows:

Figure 3 Sending a signal to a specified process

The signal is successfully sent if no error is reported.

Figure 4 Signal sending failure

The signal fails to send due to invalid parameters. Check the signal ID and PID for fault.