1# kill 2 3 4## Command Function 5 6This command is used to send a signal to a process to terminate the abnormal application. 7 8 9## Syntax 10 11kill [-l [_signo_] | _-s signo_ | _-signo_] *pid...* 12 13 14## Parameters 15 16**Table 1** Parameter description 17 18| Parameter | Description | Value Range | 19| ------ | -------------------------- | ----------- | 20| --help | Displays the parameters supported by the **kill** command.| N/A | 21| -l | Lists the names and numbers of signals. | N/A | 22| -s | Sends a signal. | N/A | 23| signo | Specifies the signal number. | [1, 30] | 24| pid | Specifies the process ID. | [1, MAX_INT] | 25 26> **NOTICE**<br> 27> The value range of **signo** is [0, 64]. The recommended value range is [1, 30], and other values in the value range are reserved. 28 29 30## Usage Guidelines 31 32- The **signo** and **pid** parameters are mandatory. 33 34- 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]. 35 36## Note 37 38The **kill** command is not supported by the shell. mksh supports it. To switch to mksh, run **cd bin;** and **./mksh**. 39 40## Example 41 42- Query the process list before killing process 42. 43 44 ``` 45 OHOS:/$ ps 46 allCpu(%): 4.67 sys, 195.33 idle 47 PID PPID PGID UID Status VirtualMem ShareMem PhysicalMem CPUUSE10s PName 48 1 -1 1 0 Pending 0x33b000 0xbb000 0x4db02 0.0 init 49 2 -1 2 0 Pending 0xdabc08 0 0xdabc08 1.14 KProcess 50 3 1 3 7 Pending 0x72e000 0x1a3000 0x1d24c2 0.0 foundation 51 4 1 4 8 Pending 0x362000 0xbb000 0x5c6ff 0.0 bundle_daemon 52 5 1 5 1 Pending 0xdfa000 0x2e7000 0x1484f0 0.0 appspawn 53 6 1 6 0 Pending 0x688000 0x137000 0x11bca0 0.0 media_server 54 7 1 7 0 Pending 0x9d2000 0x103000 0xa1cdf 0.88 wms_server 55 8 1 8 2 Pending 0x1f5000 0x48000 0x47dc2 0.2 mksh 56 10 5 5 101 Pending 0x11ec000 0x2f9000 0x206047 0.93 com.example.launcher 57 12 1 12 0 Pending 0x4d4000 0x112000 0xe0882 0.0 deviceauth_service 58 13 1 13 0 Pending 0x34f000 0xbd000 0x51799 0.0 sensor_service 59 14 1 14 2 Pending 0x34e000 0xb3000 0x52184 0.0 ai_server 60 15 1 15 0 Pending 0x61f000 0x13b000 0x168071 0.45 softbus_server 61 42 8 42 2 Pending 0x1c1000 0x3a000 0x1106a 0.9 test_demo 62 43 8 43 2 Running 0x1d7000 0x3a000 0x1e577 0.0 toybox 63 ``` 64 65- Send signal 9 (the default action of **SIGKILL** is to immediately terminate the process) to process 42 test_demo (a user-mode process). Then, check the current process list. The commands **kill -s 9 42** and **kill -9 42** have the same effect. 66 67 ``` 68 OHOS:/$ kill -s 9 42 69 OHOS:/$ 70 [1] + Killed ./nfs/test_demo 71 OHOS:/$ ps 72 allCpu(%): 4.73 sys, 195.27 idle 73 PID PPID PGID UID Status VirtualMem ShareMem PhysicalMem CPUUSE10s PName 74 1 -1 1 0 Pending 0x33b000 0xbb000 0x4e01c 0.0 init 75 2 -1 2 0 Pending 0xda5fa4 0 0xda5fa4 1.14 KProcess 76 3 1 3 7 Pending 0x72e000 0x1a3000 0x1d29dc 0.0 foundation 77 4 1 4 8 Pending 0x362000 0xbb000 0x5cc19 0.0 bundle_daemon 78 5 1 5 1 Pending 0xdfa000 0x2e7000 0x148a0a 0.0 appspawn 79 6 1 6 0 Pending 0x688000 0x137000 0x11c1ba 0.0 media_server 80 7 1 7 0 Pending 0x9d2000 0x103000 0xa21f9 0.89 wms_server 81 8 1 8 2 Pending 0x1f5000 0x48000 0x482dc 0.2 mksh 82 10 5 5 101 Pending 0x11ec000 0x2f9000 0x206561 0.93 com.example.launcher 83 12 1 12 0 Pending 0x4d4000 0x112000 0xe0d9c 0.0 deviceauth_service 84 13 1 13 0 Pending 0x34f000 0xbd000 0x51cb3 0.0 sensor_service 85 14 1 14 2 Pending 0x34e000 0xb3000 0x5269e 0.0 ai_server 86 15 1 15 0 Pending 0x61f000 0x13b000 0x16858b 0.51 softbus_server 87 45 8 45 2 Running 0x1d7000 0x3a000 0x1e9f5 0.0 toybox 88 ``` 89 90- Run the **kill -100 31** command. 91 92 93## Output 94 95The command output is as follows: 96 97Example 1: The signal is successfully sent to process 42. 98 99 100``` 101OHOS:/$ kill -s 9 42 102OHOS:/$ 103[1] + Killed ./nfs/test_demo 104``` 105 106Process 42 is killed. 107 108**Example 2**: The signal fails to be sent to process 31. 109 110 111``` 112OHOS:/$ kill -100 31 113kill: Unknown signal '(null)' 114``` 115 116**Unknown signal '(null)'** is displayed because the **signo** value **100** exceeds the value range [0, 64]. 117