Changeset ea28272 in mainline for uspace/app/kill/kill.c
- Timestamp:
- 2010-12-30T13:43:27Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d770deb
- Parents:
- d70d80ed (diff), f418e51 (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
rd70d80ed rea28272 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 /** @addtogroup kill 30 * @{ 31 */ 32 /** 33 * @file Forecfully terminate a task. 34 */ 35 36 #include <errno.h> 29 37 #include <stdio.h> 30 #include <unistd.h> 31 #include <atomic.h> 32 #include "../tester.h" 38 #include <task.h> 33 39 34 static atomic_t finish; 40 #define NAME "kill" 35 41 36 static void callback(void *priv, int retval, ipc_call_t *data)42 static void print_syntax(void) 37 43 { 38 atomic_set(&finish, 1);44 printf("Syntax: " NAME " <task ID>\n"); 39 45 } 40 46 41 const char *test_connect(void)47 int main(int argc, char *argv[]) 42 48 { 43 TPRINTF("Connecting to %u...", IPC_TEST_SERVICE);44 int phone = ipc_connect_me_to(PHONE_NS, IPC_TEST_SERVICE, 0, 0);45 i f (phone > 0) {46 TPRINTF("phoneid %d\n", phone); 47 } else{48 TPRINTF("\n");49 return "ipc_connect_me_to() failed";49 char *eptr; 50 task_id_t taskid; 51 int rc; 52 53 if (argc != 2) { 54 print_syntax(); 55 return 1; 50 56 } 51 52 printf("Sending synchronous message...\n"); 53 int retval = ipc_call_sync_0_0(phone, IPC_TEST_METHOD); 54 TPRINTF("Received response to synchronous message\n"); 55 56 TPRINTF("Sending asynchronous message...\n"); 57 atomic_set(&finish, 0); 58 ipc_call_async_0(phone, IPC_TEST_METHOD, NULL, callback, 1); 59 while (atomic_get(&finish) != 1) 60 TPRINTF("."); 61 TPRINTF("Received response to asynchronous message\n"); 62 63 TPRINTF("Hanging up..."); 64 retval = ipc_hangup(phone); 65 if (retval == 0) { 66 TPRINTF("OK\n"); 67 } else { 68 TPRINTF("\n"); 69 return "ipc_hangup() failed"; 57 58 taskid = strtoul(argv[1], &eptr, 0); 59 if (*eptr != '\0') { 60 printf("Invalid task ID argument '%s'.\n", argv[1]); 61 return 1; 70 62 } 71 72 return NULL; 63 64 rc = task_kill(taskid); 65 if (rc != EOK) { 66 printf("Failed to kill task with ID %llu (error %d)\n", 67 (unsigned long long) taskid, rc); 68 return 2; 69 } 70 71 return 0; 73 72 } 73 74 /** @} 75 */
Note:
See TracChangeset
for help on using the changeset viewer.