Added g_main_loop to handle glib events

Signed-off-by: Jimmy Huang <jimmy.huang@intel.com>