Next: , Previous: , Up: Program Self-Knowledge   [Contents][Index]

6.3.2 Executable Pathname

For purposes of finding Init5f3.scm, dumping an executable, and dynamic linking, a SCM session needs the pathname of its executable image.

When a program is executed by MS-DOS, the full pathname of that executable is available in argv[0]. This value can be passed directly to find_impl_file (see File-System Habitat).

In order to find the habitat for a unix program, we first need to know the full pathname for the associated executable file.

Function: char * dld_find_executable (const char *command)

dld_find_executable returns the absolute path name of the file that would be executed if command were given as a command. It looks up the environment variable PATH, searches in each of the directory listed for command, and returns the absolute path name for the first occurrence. Thus, it is advisable to invoke dld_init as:

main (int argc, const char **argv)
    if (dld_init (dld_find_executable (argv[0]))) {

Note@: If the current process is executed using the execve call without passing the correct path name as argument 0, dld_find_executable (argv[0]) will also fail to locate the executable file.

dld_find_executable returns zero if command is not found in any of the directories listed in PATH.