In native mode, same as Sys.executable_name, in bytecode, the path to the interpreter executing Sys.executable_name, which may not be the same from the same file.
···11111212### Standard library:
13131414+- #13728: Add Sys.runtime_executable containing the full path (if available) to
1515+ the currently executing runtime.
1616+ (David Allsopp, review by Nicolás Ojeda Bär and Daniel Bünzli)
1717+1418- #13916: Add Option.product and Option.Syntax.
1519 (Nicolás Ojeda Bär, review by Daniel Bünzli, Gabriel Scherer and David
1620 Allsopp)
+5
stdlib/sys.ml.in
···23232424external get_config: unit -> string * int * bool = "caml_sys_get_config"
2525external get_executable_name : unit -> string = "caml_sys_executable_name"
2626+external get_proc_self_exe : unit -> string option = "caml_sys_proc_self_exe"
2627external argv : string array = "%sys_argv"
2728external big_endian : unit -> bool = "%big_endian"
2829external word_size : unit -> int = "%word_size"
···3435external get_backend_type : unit -> backend_type = "%backend_type"
35363637let executable_name = get_executable_name()
3838+let runtime_executable =
3939+ match get_proc_self_exe () with
4040+ | None -> executable_name
4141+ | Some proc_self_exe -> proc_self_exe
3742let (os_type, _, _) = get_config()
3843let backend_type = get_backend_type ()
3944let big_endian = big_endian ()
+10
stdlib/sys.mli
···3232 on the platform and whether the program was compiled to bytecode or a native
3333 executable. *)
34343535+val runtime_executable : string
3636+(** The name of the file containing the runtime currently running. For
3737+ native code, this is always {!executable_name}, but in bytecode it may be
3838+ ocamlrun, for example. This name may be absolute or relative to the current
3939+ directory, depending on the platform (Linux, Windows and macOS should all
4040+ return absolute paths).
4141+4242+ @since 5.5
4343+*)
4444+3545external file_exists : string -> bool = "caml_sys_file_exists"
3646(** Test if a file with the given name exists. *)
3747