[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] Equivalent of event_self_cbarg() in libevent-2.0?



On 09/18/2012 01:28 PM, Chirag Kantharia wrote:
> Hi,
> 
> I had a signal handler which used libevent-1.4.x, and which looked
> like this:
> 
> int main (void) {
>   ...
>   struct event sigev;
>   memset(&sigev, 0, sizeof(sigev));
>   event_set(&sigev, SIGINT, EV_SIGNAL|EV_PERSIST, sig_handler, &sigev);
>   ...
>   event_dispatch();
>   return 0;
> }
> 
> The sig_handler looked like:
> 
> static void sig_handler (int fd, short event, void *arg)
> {
>   struct event *signal = arg;
>   event_del(signal);
>   exit(1);
> }
> 
> After porting it to libevent-2.0, the code in main() now looks like:
> 
> struct event *sigev;
> sigev = evsignal_new(base, SIGINT, sig_handler, NULL);
> 
> I want to send the sigev as argument to the sig_handler. I read in
> Nick's libevent book[*]  that this can be accomplished using
> event_self_cbarg(), in 2.1.1-alpha+. Do we have something in
> libevent-2.0.x for the same?
> 
See 817f374dc151 in the git repo for the old vs the new way of doing it.
I think for 2.0, you'll have to use the old way.

Regards
-- 
Ross Lagerwall

Attachment: signature.asc
Description: OpenPGP digital signature