I am playing around with custom buildins for ksh93. See the following source 
file which compiles without error into a shared library libhello.so. 

#include 

int
b_hello(int argc, char *argv[], void *extra)
{
    if (argc != 2) {
       printf("Usage: hello arg\n");
       return(2);
    }

    printf("Hello %s\n",argv[1]);

    return(0);
}

int
b_hello1(int argc, char *argv[], void *extra)
{
    if (argc != 2) {
       printf("Usage: hello1 arg\n");
       return(2);
    }

    printf("Hello1 %s\n",argv[1]);

    return(0);
}

void
lib_init(int c)
{
   printf("LIBHELLO initialized\n");
   sh_addbuiltin("hello1", b_hello1, 0);
}

I load the builtins in libhello.so as follows

   $ builtin -f ./libhello.so hello

Things works as expected if I do not call sh_addbuiltin() in lib_init() or 
elsewhere.  However if I call sh_addbuiltin() my terminal session 
disappears (killed?) without any core dump.

My questions are as follows. In lib_init() can you call sh_addbuiltin()
to load a builtin such as hello1?  The KSK-93 FAQ seems to indicate
that this should work (Q4 - SHELL EXTENSIONS)  What am I doing
wrong which is causing sh_addbuiltin() to fail?   Incorrect headers?
Do I need to include some library I am unaware of?

- FPMurphy




_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to