Changeset 93fb170c in mainline for uspace/app/kill/kill.c
- Timestamp:
- 2011-01-08T18:51:31Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 15be932
- Parents:
- 8f748215 (diff), a523af4 (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/kill/kill.c
r8f748215 r93fb170c 1 1 /* 2 * Copyright (c) 20 06 Ondrej Palkovsky2 * Copyright (c) 2010 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 #include <inttypes.h> 29 /** @addtogroup kill 30 * @{ 31 */ 32 /** 33 * @file Forcefully terminate a task. 34 */ 35 36 #include <errno.h> 30 37 #include <stdio.h> 31 #include <unistd.h> 32 #include <async.h> 33 #include <errno.h> 34 #include "../tester.h" 38 #include <task.h> 39 #include <str_error.h> 35 40 36 #define MAX_CONNECTIONS 5041 #define NAME "kill" 37 42 38 static int connections[MAX_CONNECTIONS]; 39 40 static void client_connection(ipc_callid_t iid, ipc_call_t *icall) 43 static void print_syntax(void) 41 44 { 42 unsigned int i; 43 44 TPRINTF("Connected phone %" PRIun " accepting\n", icall->in_phone_hash); 45 ipc_answer_0(iid, EOK); 46 for (i = 0; i < MAX_CONNECTIONS; i++) { 47 if (!connections[i]) { 48 connections[i] = icall->in_phone_hash; 49 break; 50 } 51 } 52 53 while (true) { 54 ipc_call_t call; 55 ipc_callid_t callid = async_get_call(&call); 56 int retval; 57 58 switch (IPC_GET_IMETHOD(call)) { 59 case IPC_M_PHONE_HUNGUP: 60 TPRINTF("Phone %" PRIun " hung up\n", icall->in_phone_hash); 61 retval = 0; 62 break; 63 case IPC_TEST_METHOD: 64 TPRINTF("Received well known message from %" PRIun ": %" PRIun "\n", 65 icall->in_phone_hash, callid); 66 ipc_answer_0(callid, EOK); 67 break; 68 default: 69 TPRINTF("Received unknown message from %" PRIun ": %" PRIun "\n", 70 icall->in_phone_hash, callid); 71 ipc_answer_0(callid, ENOENT); 72 break; 73 } 74 } 45 printf("Syntax: " NAME " <task ID>\n"); 75 46 } 76 47 77 const char *test_register(void)48 int main(int argc, char *argv[]) 78 49 { 79 async_set_client_connection(client_connection); 80 81 sysarg_t phonead; 82 int res = ipc_connect_to_me(PHONE_NS, IPC_TEST_SERVICE, 0, 0, &phonead); 83 if (res != 0) 84 return "Failed registering IPC service"; 85 86 TPRINTF("Registered as service %u, accepting connections\n", IPC_TEST_SERVICE); 87 async_manager(); 88 89 return NULL; 50 char *eptr; 51 task_id_t taskid; 52 int rc; 53 54 if (argc != 2) { 55 print_syntax(); 56 return 1; 57 } 58 59 taskid = strtoul(argv[1], &eptr, 0); 60 if (*eptr != '\0') { 61 printf("Invalid task ID argument '%s'.\n", argv[1]); 62 return 2; 63 } 64 65 rc = task_kill(taskid); 66 if (rc != EOK) { 67 printf("Failed to kill task ID %" PRIu64 ": %s\n", 68 taskid, str_error(rc)); 69 return 3; 70 } 71 72 return 0; 90 73 } 74 75 /** @} 76 */
Note:
See TracChangeset
for help on using the changeset viewer.