Kill task. * * This function is idempotent. * It signals all the task's threads to bail it out. * * @param id ID of the task to be killed. * * @return Zero on success or an error code from errno.h. * */
| 564 | * |
| 565 | */ |
| 566 | errno_t task_kill(task_id_t id) |
| 567 | { |
| 568 | if (id == 1) |
| 569 | return EPERM; |
| 570 | |
| 571 | irq_spinlock_lock(&tasks_lock, true); |
| 572 | |
| 573 | task_t *task = task_find_by_id(id); |
| 574 | if (!task) { |
| 575 | irq_spinlock_unlock(&tasks_lock, true); |
| 576 | return ENOENT; |
| 577 | } |
| 578 | |
| 579 | task_kill_internal(task); |
| 580 | irq_spinlock_unlock(&tasks_lock, true); |
| 581 | |
| 582 | return EOK; |
| 583 | } |
| 584 | |
| 585 | /** Kill the currently running task. |
| 586 | * |
no test coverage detected