session.c 880 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* vim: tabstop=4 shiftwidth=4 noexpandtab
  2. * This file is part of ToaruOS and is released under the terms
  3. * of the NCSA / University of Illinois License - see LICENSE.md
  4. * Copyright (C) 2018 K. Lange
  5. *
  6. * session - UI session manager
  7. *
  8. * Runs a background and panel for a single user and waits
  9. * for them to exit.
  10. */
  11. #include <stdlib.h>
  12. #include <stdio.h>
  13. #include <unistd.h>
  14. #include <signal.h>
  15. #include <errno.h>
  16. #include <sys/wait.h>
  17. int main(int argc, char * argv[]) {
  18. int _background_pid = fork();
  19. if (!_background_pid) {
  20. char * args[] = {"/bin/background", "--really", NULL};
  21. execvp(args[0], args);
  22. }
  23. int _panel_pid = fork();
  24. if (!_panel_pid) {
  25. char * args[] = {"/bin/panel", "--really", NULL};
  26. execvp(args[0], args);
  27. }
  28. wait(NULL);
  29. int pid;
  30. do {
  31. pid = waitpid(-1, NULL, 0);
  32. } while ((pid > 0) || (pid == -1 && errno == EINTR));
  33. return 0;
  34. }