Skip to content

Commit

Permalink
forward the exit status to the atexit hook, so it can avoid recursing…
Browse files Browse the repository at this point in the history
… as much (or call ing julia_save) during the error case
  • Loading branch information
vtjnash committed Jul 17, 2015
1 parent b4e4b4b commit 0ab5f86
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,9 @@ static struct uv_shutdown_queue_item *next_shutdown_queue_item(struct uv_shutdow
return rv;
}

DLLEXPORT void jl_atexit_hook()
DLLEXPORT void jl_atexit_hook(int exitcode)
{
julia_save();
if (exitcode == 0) julia_save();
#if defined(GC_FINAL_STATS)
jl_print_gc_stats(JL_STDERR);
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/jl_uv.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ DLLEXPORT void jl_safe_printf(const char *fmt, ...)
DLLEXPORT void jl_exit(int exitcode)
{
uv_tty_reset_mode();
jl_atexit_hook();
jl_atexit_hook(exitcode);
exit(exitcode);
}

Expand Down
10 changes: 5 additions & 5 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -1133,18 +1133,18 @@ DLLEXPORT void jl_init(const char *julia_home_dir);
DLLEXPORT void jl_init_with_image(const char *julia_home_dir, const char *image_relative_path);
DLLEXPORT int jl_is_initialized(void);
DLLEXPORT int julia_trampoline(int argc, const char *argv[], int (*pmain)(int ac,char *av[]));
DLLEXPORT void jl_atexit_hook(void);
DLLEXPORT void jl_atexit_hook(int status);
DLLEXPORT void NORETURN jl_exit(int status);

DLLEXPORT void jl_preload_sysimg_so(const char *fname);
DLLEXPORT ios_t *jl_create_system_image();
DLLEXPORT ios_t *jl_create_system_image(void);
DLLEXPORT void jl_save_system_image(const char *fname);
DLLEXPORT void jl_restore_system_image(const char *fname);
DLLEXPORT void jl_restore_system_image_data(const char *buf, size_t len);
DLLEXPORT int jl_save_incremental(const char *fname, jl_array_t* worklist);
DLLEXPORT jl_array_t *jl_restore_incremental(const char *fname);
DLLEXPORT jl_array_t *jl_restore_incremental_from_buf(const char *buf, size_t sz);
void jl_init_restored_modules();
void jl_init_restored_modules(void);

// front end interface
DLLEXPORT jl_value_t *jl_parse_input_line(const char *str, size_t len);
Expand Down Expand Up @@ -1276,7 +1276,7 @@ DLLEXPORT jl_value_t *jl_call2(jl_function_t *f, jl_value_t *a, jl_value_t *b);
DLLEXPORT jl_value_t *jl_call3(jl_function_t *f, jl_value_t *a, jl_value_t *b, jl_value_t *c);

// interfacing with Task runtime
DLLEXPORT void jl_yield();
DLLEXPORT void jl_yield(void);

// async signal handling ------------------------------------------------------

Expand Down Expand Up @@ -1530,7 +1530,7 @@ typedef struct {

extern DLLEXPORT jl_options_t jl_options;

DLLEXPORT int jl_generating_output();
DLLEXPORT int jl_generating_output(void);

// Settings for code_coverage and malloc_log
// NOTE: if these numbers change, test/cmdlineargs.jl will have to be updated
Expand Down
2 changes: 0 additions & 2 deletions src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ extern uv_lib_t *jl_crtdll_handle;
extern uv_lib_t *jl_winsock_handle;
#endif

DLLEXPORT void jl_atexit_hook();

#if defined(_CPU_X86_) || defined(_CPU_X86_64_)
#define HAVE_CPUID
#endif
Expand Down
2 changes: 1 addition & 1 deletion ui/repl.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ int wmain(int argc, wchar_t *argv[], wchar_t *envp[])
}
julia_init(imagepathspecified ? JL_IMAGE_CWD : JL_IMAGE_JULIA_HOME);
int ret = true_main(argc, (char**)argv);
jl_atexit_hook();
jl_atexit_hook(ret);
return ret;
}

Expand Down

0 comments on commit 0ab5f86

Please sign in to comment.