diff options
Diffstat (limited to 'libjava/posix.cc')
-rw-r--r-- | libjava/posix.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libjava/posix.cc b/libjava/posix.cc index ebff1c9ec79..73c0f5f4329 100644 --- a/libjava/posix.cc +++ b/libjava/posix.cc @@ -15,6 +15,7 @@ details. */ #include <stdlib.h> #include <errno.h> #include <signal.h> +#include <stdio.h> #include <jvm.h> #include <java/lang/Thread.h> @@ -25,6 +26,23 @@ details. */ extern "C" unsigned long long _clock (void); #endif +#if defined(HAVE_PROC_SELF_EXE) +static char exec_name[20]; + // initialized in _Jv_platform_initialize() +#endif + +const char *_Jv_ThisExecutable (void) +{ +#if defined(DISABLE_MAIN_ARGS) + return "[Embedded App]"; +#elif defined(HAVE_PROC_SELF_EXE) + return exec_name; + // initialized in _Jv_platform_initialize() +#else + return _Jv_GetSafeArg (0); +#endif +} + // gettimeofday implementation. jlong _Jv_platform_gettimeofday () @@ -62,6 +80,11 @@ _Jv_platform_initialize (void) #else signal (SIGPIPE, SIG_IGN); #endif + +#if defined (HAVE_PROC_SELF_EXE) + // Compute our executable name + sprintf (exec_name, "/proc/%d/exe", getpid ()); +#endif } // Set platform-specific System properties. |