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