Changeset ad7a6c9 in mainline for uspace/app/killall/killall.c
- Timestamp:
- 2011-03-30T13:10:24Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4ae90f9
- Parents:
- 6e50466 (diff), d6b81941 (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. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/killall/killall.c
r6e50466 rad7a6c9 1 1 /* 2 * Copyright (c) 20 09 Lukas Mejdrech2 * Copyright (c) 2010 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup eth29 /** @addtogroup killall 30 30 * @{ 31 31 */ 32 33 /** @file 34 * Ethernet module stub. 35 * @see module.c 32 /** 33 * @file Forcefully terminate a task specified by name. 36 34 */ 37 35 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> 39 42 40 #include <async.h> 41 #include <stdio.h> 42 #include <errno.h> 43 #define NAME "killall" 43 44 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) 45 static void print_syntax(void) 53 46 { 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"); 77 48 } 78 49 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) 50 int main(int argc, char *argv[]) 81 51 { 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; 83 81 } 84 82
Note:
See TracChangeset
for help on using the changeset viewer.