ev_default_destroy's behaviour

Robin Haberkorn rh at travelping.com
Thu Jul 22 19:29:13 CEST 2010


from the information given in the manpage I would expect that ev_default_destroy() "cleans" up the default event loop in such a way it can be reinitialized and behaves as if it was never used (as long as there were no active signal/child watchers and you don't care about the watchers that were active before the call).
In other words, I would expect a small program like this one to return immediately:

main(int argc, char **argv)
	ev_timer timer;

	ev_timer_init(&timer, timer_cb, 10., 0.);
	ev_timer_start(EV_DEFAULT_ &timer);


	ev_loop(EV_DEFAULT_ 0);

	return 0;

however it doesn't - it blocks indefinitely. Of course I can stop the watcher and everthing's fine. I just wanted to know whether ev_default_destroy() is supposed to work that way and if not exactly under which circumstances it can be useful.
I was tempted to use it once in a program where the default loop definitely makes sense (synchronizing signals without asyncs etc), at some point forks and has to clean up the default loop in the new process to allow some scripts to work with it (no execve either). I ended up stopping all watchers & resetting the still-messed-up signal handlers manually after invoking ev_default_fork().

Robin Haberkorn

------------------ managed broadband access ------------------

Travelping GmbH               phone:           +49-391-8190990
Roentgenstr. 13               fax:           +49-391-819099299
D-39108 Magdeburg             email:       info at travelping.com
GERMANY                       web:   http://www.travelping.com

Company Registration: Amtsgericht Stendal Reg No.:   HRB 10578
Geschaeftsfuehrer: Holger Winkelmann | VAT ID No.: DE236673780

More information about the libev mailing list