diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2002-02-11 13:51:40 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2002-02-11 13:51:40 +0000 |
commit | 429efbf7c2416a997d2ee5ca2d790cfdc944358b (patch) | |
tree | 13ea7ba24ad95fef48af5f6bffdee0c2f861c99d /asmrun/startup.c | |
parent | 7f765d521eb9014f42fdf0a83d3c31be897d8dd6 (diff) |
Ajout Sys.executable_name, laisser Sys.argv.(0) inchange (PR#817)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4375 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'asmrun/startup.c')
-rw-r--r-- | asmrun/startup.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/asmrun/startup.c b/asmrun/startup.c index 317339fac..8cd9ea412 100644 --- a/asmrun/startup.c +++ b/asmrun/startup.c @@ -113,6 +113,11 @@ extern void init_signals (void); void caml_main(char **argv) { + char * exe_name; +#ifdef __linux__ + static char proc_self_exe[256]; + int retcode; +#endif value res; init_ieee_floats(); @@ -125,7 +130,16 @@ void caml_main(char **argv) percent_free_init, max_percent_free_init); init_atoms(); init_signals(); - sys_init(argv); + exe_name = argv[0]; +#ifdef __linux__ + /* Recover executable name from /proc/self/exe, much more reliable */ + retcode = readlink("/proc/self/exe", proc_self_exe, sizeof(proc_self_exe)); + if (retcode != -1 && retcode < sizeof(proc_self_exe)) { + proc_self_exe[retcode] = 0; + exe_name = proc_self_exe; + } +#endif + sys_init(exe_name, argv); res = caml_start_program(); if (Is_exception_result(res)) fatal_uncaught_exception(Extract_exception(res)); |