Changeset 89c57b6 in mainline for uspace/app/killall/killall.c


Ignore:
Timestamp:
2011-04-13T14:45:41Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
88634420
Parents:
cefb126 (diff), 17279ead (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/app/killall/killall.c

    rcefb126 r89c57b6  
    2727 */
    2828
    29 /** @addtogroup il_local
    30  *  @{
     29/** @addtogroup killall
     30 * @{
     31 */
     32/**
     33 * @file Forcefully terminate a task specified by name.
    3134 */
    3235
    33 #ifndef __IL_LOCAL_H__
    34 #define __IL_LOCAL_H__
     36#include <errno.h>
     37#include <stdio.h>
     38#include <task.h>
     39#include <stats.h>
     40#include <str_error.h>
     41#include <malloc.h>
    3542
    36 #include <ipc/ipc.h>
    37 #include <async.h>
     43#define NAME  "killall"
    3844
    39 extern int il_module_message_standalone(ipc_callid_t callid, ipc_call_t *call,
    40     ipc_call_t *answer, int *answer_count);
    41 extern int il_module_start_standalone(async_client_conn_t client_connection);
     45static void print_syntax(void)
     46{
     47        printf("Syntax: " NAME " <task name>\n");
     48}
    4249
    43 #endif
     50int main(int argc, char *argv[])
     51{
     52        if (argc != 2) {
     53                print_syntax();
     54                return 1;
     55        }
     56       
     57        size_t count;
     58        stats_task_t *stats_tasks = stats_get_tasks(&count);
     59       
     60        if (stats_tasks == NULL) {
     61                fprintf(stderr, "%s: Unable to get tasks\n", NAME);
     62                return 2;
     63        }
     64       
     65        size_t i;
     66        for (i = 0; i < count; i++) {
     67                if (str_cmp(stats_tasks[i].name, argv[1]) == 0) {
     68                        task_id_t taskid = stats_tasks[i].task_id;
     69                        int rc = task_kill(taskid);
     70                        if (rc != EOK)
     71                                printf("Failed to kill task ID %" PRIu64 ": %s\n",
     72                                    taskid, str_error(rc));
     73                        else
     74                                printf("Killed task ID %" PRIu64 "\n", taskid);
     75                }
     76        }
     77       
     78        free(stats_tasks);
     79       
     80        return 0;
     81}
    4482
    4583/** @}
Note: See TracChangeset for help on using the changeset viewer.