static void fault_event(ipc_callid_t callid, ipc_call_t *call) { const char *fname; char *s_taskid; int rc; task_id_t taskid; uintptr_t thread; taskid = MERGE_LOUP32(IPC_GET_ARG1(*call), IPC_GET_ARG2(*call)); thread = IPC_GET_ARG3(*call); if (asprintf(&s_taskid, "%" PRIu64, taskid) < 0) { printf("Memory allocation failed.\n"); return; } printf(NAME ": Task %" PRIu64 " fault in thread %p.\n", taskid, (void *) thread); fname = "/app/taskdump"; #ifdef CONFIG_WRITE_CORE_FILES char *dump_fname; if (asprintf(&dump_fname, "/data/core%" PRIu64, taskid) < 0) { printf("Memory allocation failed.\n"); return; } printf(NAME ": Executing %s -c %s -t %s\n", fname, dump_fname, s_taskid); rc = task_spawnl(NULL, fname, fname, "-c", dump_fname, "-t", s_taskid, NULL); #else printf(NAME ": Executing %s -t %s\n", fname, s_taskid); rc = task_spawnl(NULL, fname, fname, "-t", s_taskid, NULL); #endif if (rc != EOK) { printf("%s: Error spawning %s (%s).\n", NAME, fname, str_error(rc)); } }
/** Fibril for spawning the task running after user connects. * * @param arg Corresponding @c telnet_user_t structure. */ static int spawn_task_fibril(void *arg) { telnet_user_t *user = arg; int rc; char term[LOC_NAME_MAXLEN]; snprintf(term, LOC_NAME_MAXLEN, "%s/%s", "/loc", user->service_name); task_id_t task; rc = task_spawnl(&task, APP_GETTERM, APP_GETTERM, "-w", term, APP_SHELL, NULL); if (rc != EOK) { telnet_user_error(user, "Spawning `%s -w %s %s' failed: %s.", APP_GETTERM, term, APP_SHELL, str_error(rc)); fibril_mutex_lock(&user->guard); user->task_finished = true; user->srvs.aborted = true; fibril_condvar_signal(&user->refcount_cv); fibril_mutex_unlock(&user->guard); return EOK; } fibril_mutex_lock(&user->guard); user->task_id = task; fibril_mutex_unlock(&user->guard); task_exit_t task_exit; int task_retval; task_wait(task, &task_exit, &task_retval); telnet_user_log(user, "%s terminated %s, exit code %d.", APP_GETTERM, task_exit == TASK_EXIT_NORMAL ? "normally" : "unexpectedly", task_retval); /* Announce destruction. */ fibril_mutex_lock(&user->guard); user->task_finished = true; user->srvs.aborted = true; fibril_condvar_signal(&user->refcount_cv); fibril_mutex_unlock(&user->guard); return EOK; }