Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 1e9f8ab in mainline


Ignore:
Timestamp:
2010-12-29T17:42:42Z (11 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
f418e51
Parents:
c41834a
Message:

Add kill command to forcefully terminate a task.

Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • boot/Makefile.common

    rc41834a r1e9f8ab  
    125125RD_APPS_NON_ESSENTIAL = \
    126126        $(USPACE_PATH)/app/edit/edit \
     127        $(USPACE_PATH)/app/kill/kill \
    127128        $(USPACE_PATH)/app/mkfat/mkfat \
    128129        $(USPACE_PATH)/app/sbi/sbi \
  • kernel/generic/include/proc/task.h

    rc41834a r1e9f8ab  
    5656#include <mm/as.h>
    5757#include <sysinfo/abi.h>
     58#include <typedefs.h>
    5859
    5960struct thread;
     
    154155
    155156extern sysarg_t sys_task_set_name(const char *, size_t);
     157extern sysarg_t sys_task_kill(task_id_t *);
    156158
    157159#endif
  • kernel/generic/include/syscall/syscall.h

    rc41834a r1e9f8ab  
    4747        SYS_TASK_GET_ID,
    4848        SYS_TASK_SET_NAME,
     49        SYS_TASK_KILL,
    4950        SYS_PROGRAM_SPAWN_LOADER,
    5051       
  • kernel/generic/src/proc/task.c

    rc41834a r1e9f8ab  
    360360}
    361361
     362/** Syscall to forcefully terminate a task
     363 *
     364 * @param uspace_taskid Pointer to task ID in user space.
     365 *
     366 * @return 0 on success or an error code from @ref errno.h.
     367 *
     368 */
     369sysarg_t sys_task_kill(task_id_t *uspace_taskid)
     370{
     371        task_id_t taskid;
     372        int rc;
     373
     374        rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(taskid));
     375        if (rc != 0)
     376                return (sysarg_t) rc;
     377
     378        return (sysarg_t) task_kill(taskid);
     379}
     380
    362381/** Find task structure corresponding to task ID.
    363382 *
  • kernel/generic/src/syscall/syscall.c

    rc41834a r1e9f8ab  
    120120        (syshandler_t) sys_task_get_id,
    121121        (syshandler_t) sys_task_set_name,
     122        (syshandler_t) sys_task_kill,
    122123        (syshandler_t) sys_program_spawn_loader,
    123124       
  • uspace/Makefile

    rc41834a r1e9f8ab  
    3838        app/getterm \
    3939        app/init \
     40        app/kill \
    4041        app/klog \
    4142        app/mkfat \
  • uspace/lib/c/generic/task.c

    rc41834a r1e9f8ab  
    6565 *
    6666 * @return Zero on success or negative error code.
    67  *
    6867 */
    6968int task_set_name(const char *name)
    7069{
    7170        return __SYSCALL2(SYS_TASK_SET_NAME, (sysarg_t) name, str_size(name));
     71}
     72
     73/** Kill a task.
     74 *
     75 * @param task_id ID of task to kill.
     76 *
     77 * @return Zero on success or negative error code.
     78 */
     79
     80int task_kill(task_id_t task_id)
     81{
     82        return (int) __SYSCALL1(SYS_TASK_KILL, (sysarg_t) &task_id);
    7283}
    7384
  • uspace/lib/c/include/task.h

    rc41834a r1e9f8ab  
    4747extern task_id_t task_get_id(void);
    4848extern int task_set_name(const char *);
     49extern int task_kill(task_id_t);
     50
    4951extern task_id_t task_spawn(const char *, const char *const[], int *);
    5052extern int task_spawnv(task_id_t *, const char *path, const char *const []);
Note: See TracChangeset for help on using the changeset viewer.