upscheme/llt
Rick Hanson 130518cdc9 get_exename() for OpenBSD. (#17)
get_exename() for OpenBSD.

Issue

`get_exename()` gets the pathname of the current process.  In
femtolisp, this is used to set the top-level `*install-dir*` which in
turn is used as the location of the system image, `flisp.boot`.

There is only a trivial implementation of `get_exename()` for OpenBSD
that simply returns `NULL`.  A minor consequence is that the unit test
will fail for the default build (make) because the system image cannot
be found.

Fix

This commit provides an implementation of `get_exename()` for OpenBSD,
so that the system image can be found.

Unlike, say, Linux or FreeBSD, OpenBSD doesn't have a system call to
get the path of the current (or any, for that matter) process.  The
present code contains some logic that was put together to emulate the
behavior of the Linux and FreeBSD variants of `get_exename()` as best
as possible.  It works as described by the following.

(1) Call `sysctl(3)` (with `CTL_KERN` -> `KERN_PROC_ARGS` ->
    `KERN_PROC_ARGV`) to get the "`argv[0]`" of the current process.
    If the program (flisp) was called in "`basename` form" (i.e. as
    "flisp"), then go to (2).  Otherwise, return the value from
    `sysctl(3)` which will be an absolute or relative pathname,
    e.g. "/usr/local/bin/flisp" or  "../flisp".

    The code for (1) was adapted from old OpenBSD-specific `tmux` code
    that has since been abandoned by the author only because he deemed
    it "too expensive".  For that code, see

    8c259f562b/tree/osdep-openbsd.c

(2) Since we now only have "flisp", we need to find out where it is
    located on the system.  We assume that a program like the shell
    had to crawl `PATH` to find "flisp"; hence we do the same.

    The code for (2) was adapted from the `which` utility in OpenBSD.
    See

    http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/usr.bin/which/which.c?rev=1.20&content-type=text/plain

Finally, any error condition returns `NULL`, which is the same
behavior of the other `get_exename()` variants.

* Resolve relative pathnames to absolute, for OpenBSD get_exename().
2019-08-08 18:09:02 +03:00
..
Makefile Make FreeBSD a "first class citizen" among femtolisp's build OSes. 2019-08-08 18:09:02 +03:00
Makefile.macosx remove more unused stuff 2019-08-08 18:09:02 +03:00
UTF8.txt adding new UTF8 example text 2008-09-03 18:39:27 +00:00
bitvector-ops.c clarifying which values are unspecified, and making the unspecified value 2010-01-06 18:27:28 +00:00
bitvector.c getting rid of label 2010-12-23 06:49:37 +00:00
bitvector.h misc. updates, mostly about portability and warnings 2010-08-04 19:03:19 +00:00
dirpath.c get_exename() for OpenBSD. (#17) 2019-08-08 18:09:02 +03:00
dirpath.h added globals *install-dir* and *print-width*, parameterized 2008-09-11 02:37:38 +00:00
dtypes.h Make FreeBSD a "first class citizen" among femtolisp's build OSes. 2019-08-08 18:09:02 +03:00
dump.c misc. updates, mostly about portability and warnings 2010-08-04 19:03:19 +00:00
hashing.c misc. updates, mostly about portability and warnings 2010-08-04 19:03:19 +00:00
hashing.h porting over some minor changes to LLT 2010-05-02 18:28:53 +00:00
htable.c some LLT cleanup: 2010-02-25 04:37:33 +00:00
htable.h allowing multiple expressions in lambda 2009-05-29 04:38:50 +00:00
htable.inc fix a use-after-free memory bug 2019-08-08 18:09:02 +03:00
htableh.inc making all builtins print readably; (builtin 'sym) function 2008-12-21 05:55:00 +00:00
ieee754.h misc. updates, mostly about portability and warnings 2010-08-04 19:03:19 +00:00
int2str.c adding \e character escape 2010-08-28 05:07:02 +00:00
ios.c fix bug in file-not-found due to incomplete init of the ios_t 2019-08-08 18:09:02 +03:00
ios.h some fixes to ios 2012-01-17 04:31:08 +00:00
llt.h some LLT cleanup: 2010-02-25 04:37:33 +00:00
lltinit.c misc. updates, mostly about portability and warnings 2010-08-04 19:03:19 +00:00
lookup3.c import of llt library source 2008-07-01 01:53:51 +00:00
mt19937ar.c adding \e character escape 2010-08-28 05:07:02 +00:00
ptrhash.c misc. updates, mostly about portability and warnings 2010-08-04 19:03:19 +00:00
ptrhash.h support reading hex float literals 2008-11-23 07:12:37 +00:00
random.c misc. updates, mostly about portability and warnings 2010-08-04 19:03:19 +00:00
random.h misc. updates, mostly about portability and warnings 2010-08-04 19:03:19 +00:00
socket.c improved implementation of backquote 2011-04-11 03:24:30 +00:00
socket.h improved implementation of backquote 2011-04-11 03:24:30 +00:00
timefuncs.c Make FreeBSD a "first class citizen" among femtolisp's build OSes. 2019-08-08 18:09:02 +03:00
timefuncs.h porting over some minor changes to LLT 2010-05-02 18:28:53 +00:00
utf8.c Add support for OpenBSD 2019-08-08 18:09:02 +03:00
utf8.h add wcwidth.c for windows 2019-08-08 18:09:02 +03:00
utils.h trying some preprocessor platform detection 2013-03-17 15:02:33 -04:00
wcwidth.c add wcwidth.c for windows 2019-08-08 18:09:02 +03:00