scsh-users
[Top] [All Lists]

dynload.c and bsd/waitcodes.scm

To: Alan Bawden <Alan@LCS.MIT.EDU>
Subject: dynload.c and bsd/waitcodes.scm
From: Martin Cracauer <cracauer@wavehh.hanse.de>
Date: Wed, 8 Jan 97 11:58:39 +0100
Cc: scsh-bugs@martigny.ai.mit.edu
Alan Bawden writes:
> Two problems to report in scsh 0.4.4:
> 
> ------- #1
> 
> scsh-0.4.4/dynload.c contains the following code:
> 
>     newhandle=dlopen(pathname, S48_DLOPEN_MODE);
>   #if defined(__NetBSD__) || defined(__FreeBSD__)
>     if (newhandle == -1) {
>       fprintf(stderr, " dynamic_load of %s can't dlopen %s",
>             sharedobjname, pathname);
>       return -1;
>     };
>   #else
>     if (!newhandle) {
>       fprintf(stderr, " dynamic_load of %s can't dlopen %s: %s ",
>             sharedobjname, pathname, dlerror());
>       return -1;
>     };
>   #endif
> 
> First off, the manual page for dlopen() on FreeBSD version 2.1.0
> claims that dlopen returns a null pointer if it fails.  That manual page
> also claims that dlerror() is supported.  I do seem to recall that previous
> versions of FreeBSD had some undocumented dynamic loading support, so
> perhaps this code is a hold-over from those old days.  Probably autoconf
> should be figuring this out for you somehow...

FreeBSD, NetBSD (and therefore OpenBSD) return NULL when dlopen fails
and support dlerror.

I checked the FreeBSD CVS files and this feature is support at least
since FreeBSD-2.0 (start of CVS files). My NetBSD 1.0 also claims so.

I can only suspect the different dlopen support was in 386BSD, and
inherited to FreeBSD-1.x and NetBSD <1.0.

I would change the code to check for all platforms

     if (newhandle<=0) {

The remaining problem could be a missing dlerror(), but I don't think
such old BSD releases are still in use. If ignoring the problem is not
an option for you, I could send you code to test for FreeBSD<2.0 and
ask NetBSD people about the issue.

> Second off, this code generates a compile-time warning because of the
> comparison between newhandle and -1.  Since this is the -only- warning I
> got when installing scsh, you might want to achieve perfection by replacing
> that "-1" with "(void *) -1"!
> 
> ------- #2
> 
> In scsh-0.4.4/scsh/bsd/waitcodes.scm the line:
> 
>        (not (= #x7F))                                 ; Not suspended.
> 
> should probably read:
> 
>        (not (= #x7F termsig))                         ; Not suspended.
> 
> ------- EOM
-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Martin Cracauer <cracauer@wavehh.hanse.de>
http://cracauer.cons.org
Fax +49 40 522 85 36 

<Prev in Thread] Current Thread [Next in Thread>