Support graphical session logout.

You can log out by exiting the terminal for now, this will later be "by
exiting the wallpaper application" or something to that effect, and will
be triggered by an on-screen button or keybinding.

[ci skip]
This commit is contained in:
Kevin Lange 2012-09-13 00:09:17 -07:00
parent cea692b577
commit 08f6a66e6a

View File

@ -1,34 +1,38 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <syscall.h>
volatile int _end_session = 0;
void sig_int(int sig) {
_end_session = 1;
}
int main(int argc, char * argv[]) {
/* Starts a graphical session and then spins waiting for a kill (logout) signal */
syscall_signal(2, sig_int);
if (!fork()) {
int _wallpaper_pid = fork();
if (!_wallpaper_pid) {
char * args[] = {"/bin/wallpaper", NULL};
execve(args[0], args, NULL);
}
if (!fork()) {
int _panel_pid = fork();
if (!_panel_pid) {
char * args[] = {"/bin/panel", NULL};
execve(args[0], args, NULL);
}
if (!fork()) {
int _terminal_pid = fork();
if (!_terminal_pid) {
char * args[] = {"/bin/terminal", NULL};
execve(args[0], args, NULL);
}
syscall_wait(_terminal_pid);
printf("Terminal has exited. Sending kill signals to %d and %d.\n", _wallpaper_pid, _panel_pid);
syscall_send_signal(_wallpaper_pid, 2);
syscall_send_signal(_panel_pid, 2);
printf("Waiting on wallpaper.\n");
syscall_wait(_wallpaper_pid);
printf("Waiting on panel.\n");
syscall_wait(_panel_pid);
while (!_end_session) {
syscall_yield();
}
}