Re: wrapping the linux "C" signal function

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Wed, 19 Jul 2000, Jeffrey Fielding wrote:

> If you look at the man page on linux, and scroll down a bit, it gives a better
> expnanation:
> ------------------------from man signal--------------
> If you're confused by the prototype at  the  top  of  this
>        manpage, it may help to see it separated out thus:
>
>        typedef void (*sighandler_t)(int);
>        sighandler_t signal(int signum, sighandler_t handler)
> -------------------------------------------------
> The return value is a pointer, either the handler, or SIG_ERR if there's an
> error.
> The signum argument is a standard C_INT. It's passed by value, not by a
> reference
> (pointer).
> The handler argument is a pointer to a void function (procedure) which takes
> one
> argument (an int), which is the signal number.
> Here's an (untested) example:
>
> include dll.e
> include machine.e
> constant STDLIB = open_dll("")
> constant SIGNAL = define_c_func(STDLIB,"signal",{C_INT,C_POINTER},C_POINTER)
> -- routine is the routine_id of a procedure with 1 integer argument (the
> handler)
> -- return 0 if everything is ok, 1 if there's an error
> function c_signal(integer signum, integer routine)
>     atom ptr, r
>     ptr = call_back(routine)
>     r = c_func(SIGNAL,{signum,ptr})
>     if r = ptr then
>         return 0
>     else
>         return 1
>     end if
> end function
>
> Jeff Fielding
> JJProg at cyberbury.net

thanks for the quick response, looks like i was just a *little* off track
there. just one more thing, since i have not done alot of lower level
programming or routine_ids except for this wrapper lib im writing, what does the
call_back() routine actually do?

--
cense,
a member of the
ak-software development team

http://www.ak-software.com/

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu