Changes in uspace/srv/taskmon/taskmon.c [b688fd8:9d58539] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/taskmon/taskmon.c
rb688fd8 r9d58539 1 1 /* 2 * Copyright (c) 201 3Jiri Svoboda2 * Copyright (c) 2010 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 40 40 #include <sys/typefmt.h> 41 41 #include <task.h> 42 #include <ipc/corecfg.h> 43 #include <loc.h> 42 #include <event.h> 44 43 #include <macros.h> 45 44 #include <errno.h> … … 48 47 #define NAME "taskmon" 49 48 50 static bool write_core_files; 51 52 static void corecfg_client_conn(ipc_callid_t , ipc_call_t *, void *); 53 54 static void fault_event(ipc_callid_t callid, ipc_call_t *call, void *arg) 49 static void fault_event(ipc_callid_t callid, ipc_call_t *call) 55 50 { 56 51 const char *fname; 57 52 char *s_taskid; 58 char *dump_fname;59 53 int rc; 60 54 … … 75 69 fname = "/app/taskdump"; 76 70 77 if (write_core_files) { 78 if (asprintf(&dump_fname, "/data/core%" PRIu64, taskid) < 0) { 79 printf("Memory allocation failed.\n"); 80 return; 81 } 71 #ifdef CONFIG_WRITE_CORE_FILES 72 char *dump_fname; 82 73 83 printf(NAME ": Executing %s -c %s -t %s\n", fname, dump_fname, s_taskid); 84 rc = task_spawnl(NULL, NULL, fname, fname, "-c", dump_fname, "-t", s_taskid, 85 NULL); 86 } else { 87 printf(NAME ": Executing %s -t %s\n", fname, s_taskid); 88 rc = task_spawnl(NULL, NULL, fname, fname, "-t", s_taskid, NULL); 74 if (asprintf(&dump_fname, "/data/core%" PRIu64, taskid) < 0) { 75 printf("Memory allocation failed.\n"); 76 return; 89 77 } 90 78 79 printf(NAME ": Executing %s -c %s -t %s\n", fname, dump_fname, s_taskid); 80 rc = task_spawnl(NULL, fname, fname, "-c", dump_fname, "-t", s_taskid, 81 NULL); 82 #else 83 printf(NAME ": Executing %s -t %s\n", fname, s_taskid); 84 rc = task_spawnl(NULL, fname, fname, "-t", s_taskid, NULL); 85 #endif 91 86 if (rc != EOK) { 92 87 printf("%s: Error spawning %s (%s).\n", NAME, fname, 93 88 str_error(rc)); 94 }95 }96 97 static void corecfg_get_enable_srv(ipc_callid_t iid, ipc_call_t *icall)98 {99 async_answer_1(iid, EOK, write_core_files);100 }101 102 static void corecfg_set_enable_srv(ipc_callid_t iid, ipc_call_t *icall)103 {104 write_core_files = IPC_GET_ARG1(*icall);105 async_answer_0(iid, EOK);106 }107 108 static void corecfg_client_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)109 {110 /* Accept the connection */111 async_answer_0(iid, EOK);112 113 while (true) {114 ipc_call_t call;115 ipc_callid_t callid = async_get_call(&call);116 sysarg_t method = IPC_GET_IMETHOD(call);117 118 if (!method) {119 /* The other side has hung up */120 async_answer_0(callid, EOK);121 return;122 }123 124 switch (method) {125 case CORECFG_GET_ENABLE:126 corecfg_get_enable_srv(callid, &call);127 break;128 case CORECFG_SET_ENABLE:129 corecfg_set_enable_srv(callid, &call);130 break;131 }132 89 } 133 90 } … … 137 94 printf("%s: Task Monitoring Service\n", NAME); 138 95 139 #ifdef CONFIG_WRITE_CORE_FILES 140 write_core_files = true; 141 #else 142 write_core_files = false; 143 #endif 144 if (async_event_subscribe(EVENT_FAULT, fault_event, NULL) != EOK) { 96 if (event_subscribe(EVENT_FAULT, 0) != EOK) { 145 97 printf("%s: Error registering fault notifications.\n", NAME); 146 98 return -1; 147 99 } 148 100 149 async_set_fallback_port_handler(corecfg_client_conn, NULL); 150 151 int rc = loc_server_register(NAME); 152 if (rc != EOK) { 153 printf("%s: Failed registering server (%d).\n", 154 NAME, rc); 155 return -1; 156 } 157 158 service_id_t sid; 159 rc = loc_service_register(SERVICE_NAME_CORECFG, &sid); 160 if (rc != EOK) { 161 printf("%s: Failed registering service (%d).\n", 162 NAME, rc); 163 return -1; 164 } 165 101 async_set_interrupt_received(fault_event); 166 102 task_retval(0); 167 103 async_manager();
Note:
See TracChangeset
for help on using the changeset viewer.