Changeset b5e68c8 in mainline for uspace/app/killall/killall.c
- Timestamp:
- 2011-05-12T16:49:44Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f36787d7
- Parents:
- e80329d6 (diff), 750636a (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
re80329d6 rb5e68c8 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 <err.h> 43 #define NAME "killall" 43 44 44 #include <ipc/ipc.h> 45 #include <ipc/services.h> 45 static void print_syntax(void) 46 { 47 printf("Syntax: " NAME " <task name>\n"); 48 } 46 49 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) 50 int main(int argc, char *argv[]) 53 51 { 54 ERROR_DECLARE; 55 56 async_set_client_connection(client_connection); 57 int net_phone = net_connect_module(); 58 ERROR_PROPAGATE(pm_init()); 59 60 ipcarg_t phonehash; 61 if (ERROR_OCCURRED(nil_initialize(net_phone)) || 62 ERROR_OCCURRED(REGISTER_ME(SERVICE_ETHERNET, &phonehash))) { 63 pm_destroy(); 64 return ERROR_CODE; 52 if (argc != 2) { 53 print_syntax(); 54 return 1; 65 55 } 66 56 67 async_manager(); 57 size_t count; 58 stats_task_t *stats_tasks = stats_get_tasks(&count); 68 59 69 pm_destroy(); 70 return EOK; 71 } 72 73 int 74 nil_module_message_standalone(const char *name, ipc_callid_t callid, 75 ipc_call_t *call, ipc_call_t *answer, int *answer_count) 76 { 77 return nil_message_standalone(name, callid, call, answer, answer_count); 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; 78 81 } 79 82
Note:
See TracChangeset
for help on using the changeset viewer.