static void lxsession_stop(LXSession *s) { if(s->greeter) { ui_drop(); s->greeter=FALSE; } if(s->child>0) { lxcom_del_child_watch(s->child); killpg(s->child, SIGHUP); stop_pid(s->child); s->child = -1; } if( s->server > 0 ) { xconn_clean(s->dpy); } lxdm_auth_session_end(&s->auth); #if HAVE_LIBCK_CONNECTOR if( s->ckc != NULL ) { DBusError error; dbus_error_init(&error); ck_connector_close_session(s->ckc, &error); if(dbus_error_is_set(&error)) { dbus_error_free(&error); } ck_connector_unref(s->ckc); s->ckc=NULL; } #endif s->idle=TRUE; }
void ui_drop(void) { /* if greeter, do quit */ if( greeter > 0 ) { lxcom_del_child_watch(greeter); xwrite(greeter_pipe[0], "exit\n", 5); g_source_remove(io_id); io_id = 0; g_io_channel_unref(greeter_io); greeter_io = NULL; close(greeter_pipe[1]); close(greeter_pipe[0]); waitpid(greeter, 0, 0) ; greeter=-1; user=-1; } if(io_id>0) { g_source_remove(io_id); io_id = 0; g_io_channel_unref(greeter_io); greeter_io = NULL; close(greeter_pipe[1]); close(greeter_pipe[0]); } }
void stop_pid(int pid) { if( pid <= 0 ) return; lxcom_del_child_watch(pid); if( killpg(pid, SIGTERM) < 0 ) killpg(pid, SIGKILL); if( kill(pid, 0) == 0 ) { if( kill(pid, SIGTERM) ) kill(pid, SIGKILL); } while( 1 ) { int wpid, status; wpid = waitpid(pid,&status,0); if(pid == wpid) break; if(wpid<0 && errno!=EINTR) break; } while( waitpid(-1, 0, WNOHANG) > 0 ) ; }