* @brief Command handler for killing processes * * @param[in] argc Argument count * @param[in] argv Argument vector (contains PID and optional signal) * * @note Usage: * - kill * - kill -s * Default signal is SIGKILL (9) */
| 1846 | * Default signal is SIGKILL (9) |
| 1847 | */ |
| 1848 | static void cmd_kill(int argc, char** argv) |
| 1849 | { |
| 1850 | int pid; |
| 1851 | int sig = SIGKILL; |
| 1852 | |
| 1853 | if (argc < 2) |
| 1854 | { |
| 1855 | rt_kprintf("kill pid or kill pid -s signal\n"); |
| 1856 | return; |
| 1857 | } |
| 1858 | |
| 1859 | pid = atoi(argv[1]); |
| 1860 | if (argc >= 4) |
| 1861 | { |
| 1862 | if (argv[2][0] == '-' && argv[2][1] == 's') |
| 1863 | { |
| 1864 | sig = atoi(argv[3]); |
| 1865 | } |
| 1866 | } |
| 1867 | lwp_pid_lock_take(); |
| 1868 | lwp_signal_kill(lwp_from_pid_raw_locked(pid), sig, SI_USER, 0); |
| 1869 | lwp_pid_lock_release(); |
| 1870 | } |
| 1871 | MSH_CMD_EXPORT_ALIAS(cmd_kill, kill, send a signal to a process); |
| 1872 | |
| 1873 | /** |
nothing calls this directly
no test coverage detected