Otherwise, it might call signal_del() and file_del() on another
(or even undefined) context.
void
main_delete(struct main_context *m)
{
+ struct main_context *prev = main_switch_context(m);
+
if (m->sigchld_handler)
signal_del(m->sigchld_handler);
if (m->sig_pipe_file)
#endif
xfree(m);
// FIXME: Some mechanism for cleaning up after fork()
+
+ main_switch_context((prev == m) ? NULL : prev);
}
struct main_context *
void
main_cleanup(void)
{
- struct main_context *m = main_switch_context(NULL);
- main_delete(m);
+ main_delete(main_current());
}
void