Changeset 80cd7cd in mainline for uspace/app/killall/killall.c


Ignore:
Timestamp:
2011-01-13T20:58:24Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
87e373b
Parents:
eaef141 (diff), a613fea1 (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

    reaef141 r80cd7cd  
    11/*
    2  * Copyright (c) 2009 Lukas Mejdrech
     2 * Copyright (c) 2010 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup eth
     29/** @addtogroup killall
    3030 * @{
    3131 */
    32 
    33 /** @file
    34  *  Ethernet module stub.
    35  *  @see module.c
     32/**
     33 * @file Forcefully terminate a task specified by name.
    3634 */
    3735
    38 #include "eth.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>
    3942
    40 #include <async.h>
    41 #include <stdio.h>
    42 #include <errno.h>
     43#define NAME  "killall"
    4344
    44 #include <ipc/ipc.h>
    45 #include <ipc/services.h>
    46 
    47 #include <net/modules.h>
    48 #include <net_interface.h>
    49 #include <net/packet.h>
    50 #include <nil_local.h>
    51 
    52 int nil_module_start_standalone(async_client_conn_t client_connection)
     45static void print_syntax(void)
    5346{
    54         sysarg_t phonehash;
    55         int rc;
    56        
    57         async_set_client_connection(client_connection);
    58         int net_phone = net_connect_module();
    59 
    60         rc = pm_init();
    61         if (rc != EOK)
    62                 return rc;
    63        
    64         rc = nil_initialize(net_phone);
    65         if (rc != EOK)
    66                 goto out;
    67 
    68         rc = ipc_connect_to_me(PHONE_NS, SERVICE_ETHERNET, 0, 0, &phonehash);
    69         if (rc != EOK)
    70                 goto out;
    71        
    72         async_manager();
    73 
    74 out:
    75         pm_destroy();
    76         return rc;
     47        printf("Syntax: " NAME " <task name>\n");
    7748}
    7849
    79 int nil_module_message_standalone(const char *name, ipc_callid_t callid,
    80     ipc_call_t *call, ipc_call_t *answer, int *answer_count)
     50int main(int argc, char *argv[])
    8151{
    82         return nil_message_standalone(name, callid, call, answer, answer_count);
     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;
    8381}
    8482
Note: See TracChangeset for help on using the changeset viewer.