int true_main(int argc, char *argv[]) { if (jl_base_module != NULL) { jl_array_t *args = (jl_array_t*)jl_get_global(jl_base_module, jl_symbol("ARGS")); assert(jl_array_len(args) == 0); jl_array_grow_end(args, argc); int i; for (i=0; i < argc; i++) { jl_value_t *s = (jl_value_t*)jl_cstr_to_string(argv[i]); s->type = (jl_value_t*)jl_utf8_string_type; jl_arrayset(args, s, i); } } // run program if specified, otherwise enter REPL if (program) { int ret = exec_program(); uv_tty_reset_mode(); return ret; } jl_function_t *start_client = (jl_function_t*)jl_get_global(jl_base_module, jl_symbol("_start")); //uv_read_start(jl_stdin_tty,jl_alloc_read_buffer,&read_buffer); if (start_client) { jl_apply(start_client, NULL, 0); //rl_cleanup_after_signal(); return 0; } // client event loop not available; use fallback blocking version //install_read_event_handler(&echoBack); int iserr = 0; again: ; JL_TRY { if (iserr) { //jl_show(jl_exception_in_transit);# What if the error was in show? jl_printf(JL_STDERR, "\n\n"); iserr = 0; } uv_run(jl_global_event_loop(),UV_RUN_DEFAULT); } JL_CATCH { iserr = 1; JL_PUTS("error during run:\n",JL_STDERR); jl_show(jl_stderr_obj(),jl_exception_in_transit); JL_PUTS("\n",JL_STDOUT); goto again; } uv_tty_reset_mode(); return iserr; }
int true_main(int argc, char *argv[]) { if (jl_base_module != NULL) { jl_array_t *args = (jl_array_t*)jl_get_global(jl_base_module, jl_symbol("ARGS")); if (args == NULL) { args = jl_alloc_cell_1d(0); jl_set_const(jl_base_module, jl_symbol("ARGS"), (jl_value_t*)args); } assert(jl_array_len(args) == 0); jl_array_grow_end(args, argc); int i; for (i=0; i < argc; i++) { jl_value_t *s = (jl_value_t*)jl_cstr_to_string(argv[i]); s->type = (jl_value_t*)jl_utf8_string_type; jl_arrayset(args, s, i); } } // run program if specified, otherwise enter REPL if (program) { int ret = exec_program(); uv_tty_reset_mode(); return ret; } jl_function_t *start_client = (jl_function_t*)jl_get_global(jl_base_module, jl_symbol("_start")); if (start_client) { jl_apply(start_client, NULL, 0); return 0; } int iserr = 0; again: ; JL_TRY { if (iserr) { //jl_show(jl_exception_in_transit);# What if the error was in show? jl_printf(JL_STDERR, "\n\n"); iserr = 0; } uv_run(jl_global_event_loop(),UV_RUN_DEFAULT); } JL_CATCH { iserr = 1; JL_PUTS("error during run:\n",JL_STDERR); jl_show(jl_stderr_obj(),jl_exception_in_transit); JL_PUTS("\n",JL_STDOUT); goto again; } uv_tty_reset_mode(); return iserr; }
static PyObject * TTY_func_reset_mode(PyObject *cls) { UNUSED_ARG(cls); uv_tty_reset_mode(); Py_RETURN_NONE; }
void segv_handler(int sig, siginfo_t *info, void *context) { sigset_t sset; if ( #ifdef COPY_STACKS (char*)info->si_addr > (char*)jl_stack_lo-3000000 && (char*)info->si_addr < (char*)jl_stack_hi #else (char*)info->si_addr > (char*)jl_current_task->stack-8192 && (char*)info->si_addr < (char*)jl_current_task->stack+jl_current_task->ssize #endif ) { sigemptyset(&sset); sigaddset(&sset, SIGSEGV); sigprocmask(SIG_UNBLOCK, &sset, NULL); jl_throw(jl_stackovf_exception); } else { uv_tty_reset_mode(); sigfillset(&sset); sigprocmask(SIG_UNBLOCK, &sset, NULL); signal(sig, SIG_DFL); if (sig != SIGSEGV && sig != SIGBUS && sig != SIGILL) raise(sig); } }
DLLEXPORT void jl_exit(int exitcode) { /*if (jl_io_loop) { jl_process_events(&jl_io_loop); }*/ uv_tty_reset_mode(); uv_atexit_hook(); exit(exitcode); }
App::~App() { uv_tty_reset_mode(); # ifndef XMRIG_NO_HTTPD delete m_httpd; # endif delete m_console; }
static void freeVM() { ioShutdown(); schedulerShutdown(); uv_loop_close(loop); free(loop); wrenFreeVM(vm); uv_tty_reset_mode(); }
App::~App() { uv_tty_reset_mode(); delete m_console; delete m_controller; # ifndef XMRIG_NO_HTTPD delete m_httpd; # endif Log::release(); }
void sigdie_handler(int sig, siginfo_t *info, void *context) { sigset_t sset; uv_tty_reset_mode(); jl_critical_error(sig, jl_to_bt_context(context), jl_bt_data, &jl_bt_size); sigfillset(&sset); sigprocmask(SIG_UNBLOCK, &sset, NULL); signal(sig, SIG_DFL); if (sig != SIGSEGV && sig != SIGBUS && sig != SIGILL) { raise(sig); } // fall-through return to re-execute faulting statement (but without the error handler) }
void update(uv_timer_t *req, int status) { char data[500]; uv_buf_t buf; buf.base = data; buf.len = sprintf(data, "\033[2J\033[H\033[%dB\033[%dC\033[42;37m%s", pos, (width-strlen(message))/2, message); uv_write(&write_req, (uv_stream_t*) &tty, &buf, 1, NULL); pos++; if (pos > height) { uv_tty_reset_mode(); uv_timer_stop(&tick); } }
int main() { loop = uv_default_loop(); uv_tty_init(loop, &tty, 1, 0); uv_tty_set_mode(&tty, 0); if (uv_tty_get_winsize(&tty, &width, &height)) { fprintf(stderr, "Could not get TTY information\n"); uv_tty_reset_mode(); return 1; } fprintf(stderr, "Width %d, height %d\n", width, height); uv_timer_init(loop, &tick); uv_timer_start(&tick, update, 200, 200); return uv_run(loop, UV_RUN_DEFAULT); }
void sigdie_handler(int sig, siginfo_t *info, void *context) { sigset_t sset; uv_tty_reset_mode(); sigfillset(&sset); sigprocmask(SIG_UNBLOCK, &sset, NULL); signal(sig, SIG_DFL); #ifdef __APPLE__ jl_critical_error(sig, (bt_context_t)&((ucontext64_t*)context)->uc_mcontext64->__ss, jl_bt_data, &jl_bt_size); #else jl_critical_error(sig, (ucontext_t*)context, jl_bt_data, &jl_bt_size); #endif if (sig != SIGSEGV && sig != SIGBUS && sig != SIGILL) { raise(sig); } // fall-through return to re-execute faulting statement (but without the error handler) }
void segv_handler(int sig, siginfo_t *info, void *context) { sigset_t sset; if (in_jl_ || is_addr_on_stack(info->si_addr)) { sigemptyset(&sset); sigaddset(&sset, SIGSEGV); sigprocmask(SIG_UNBLOCK, &sset, NULL); jl_throw(jl_stackovf_exception); } else { uv_tty_reset_mode(); sigfillset(&sset); sigprocmask(SIG_UNBLOCK, &sset, NULL); signal(sig, SIG_DFL); if (sig != SIGSEGV && sig != SIGBUS && sig != SIGILL) raise(sig); } }
void sigdie_handler(int sig, siginfo_t *info, void *context) { if (sig != SIGINFO) { sigset_t sset; uv_tty_reset_mode(); sigfillset(&sset); sigprocmask(SIG_UNBLOCK, &sset, NULL); signal(sig, SIG_DFL); } jl_safe_printf("\nsignal (%d): %s\n", sig, strsignal(sig)); #ifdef __APPLE__ bt_size = rec_backtrace_ctx(bt_data, MAX_BT_SIZE, (bt_context_t)&((ucontext64_t*)context)->uc_mcontext64->__ss); #else bt_size = rec_backtrace_ctx(bt_data, MAX_BT_SIZE, (ucontext_t*)context); #endif jlbacktrace(); if (sig != SIGSEGV && sig != SIGBUS && sig != SIGILL && sig != SIGINFO) { raise(sig); } }
static int luv_tty_reset_mode(lua_State* L) { int ret = uv_tty_reset_mode(); if (ret < 0) return luv_error(L, ret); lua_pushinteger(L, ret); return 1; }
JL_DLLEXPORT void jl_exit(int exitcode) { uv_tty_reset_mode(); jl_atexit_hook(exitcode); exit(exitcode); }
SCM TTY::ResetMode(){ uv_tty_reset_mode(); return SCM_BOOL_T; }
int luv_tty_reset_mode(lua_State* L) { uv_tty_reset_mode(); return 0; }