session.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. char path[1024];
  19. char * home = getenv("HOME");
  20. if (home) {
  21. sprintf(path, "%s/.yutanirc", home);
  22. char * args[] = {path, NULL};
  23. execvp(args[0], args);
  24. }
  25. /* Fallback */
  26. int _background_pid = fork();
  27. if (!_background_pid) {
  28. char * args[] = {"/bin/background", "--really", NULL};
  29. execvp(args[0], args);
  30. }
  31. int _panel_pid = fork();
  32. if (!_panel_pid) {
  33. char * args[] = {"/bin/panel", "--really", NULL};
  34. execvp(args[0], args);
  35. }
  36. wait(NULL);
  37. int pid;
  38. do {
  39. pid = waitpid(-1, NULL, 0);
  40. } while ((pid > 0) || (pid == -1 && errno == EINTR));
  41. return 0;
  42. }