Move the event loop to evtloop.c, and wake up sleeping jobs every 10 seconds.
[apps/madmutt.git] / main.c
diff --git a/main.c b/main.c
index 2d52aa9..af2141e 100644 (file)
--- a/main.c
+++ b/main.c
 #include <lib-lib/lib-lib.h>
 
 #include <sys/utsname.h>
+#include <pthread.h>
 
 #include <lib-lua/lib-lua.h>
 #include <lib-sys/mutt_signal.h>
+#include <lib-sys/evtloop.h>
 #include <lib-mime/mime.h>
 #include <lib-ui/lib-ui.h>
 #include <lib-mx/mx.h>
@@ -188,6 +190,7 @@ int main (int argc, char **argv)
   int version = 0;
   int i;
   int explicit_folder = 0;
+  pthread_t pt;
 
   /* initialize random number for tmp file creation */ 
   srand48((unsigned int) time (NULL));
@@ -303,8 +306,10 @@ int main (int argc, char **argv)
   }
 
   /* set defaults and read init files */
+  el_initialize();
   mutt_init (flags & M_NOSYSRC, commands);
   string_list_wipe(&commands);
+  pthread_create(&pt, NULL, &el_loop, NULL);
 
   if (!option(OPTNOCURSES)) {
       ui_layout_init();
@@ -490,6 +495,7 @@ int main (int argc, char **argv)
                                    NULL)) || !explicit_folder)
     {
       mutt_index_menu ();
+
       if (option (OPTXTERMSETTITLES))
         printf("\033]2;%s\007", NONULL(XtermLeave));
       if (Context)
@@ -498,7 +504,10 @@ int main (int argc, char **argv)
     mutt_endwin (Errorbuf);
   }
 
+  pthread_cancel(pt);
+  pthread_join(pt, NULL);
   luaM_shutdown();
   mutt_sasl_shutdown();
+  el_shutdown();
   exit (0);
 }