login-loop.c 655 B

1234567891011121314151617181920212223242526272829303132
  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. * login-loop - Continuously call `login`
  7. *
  8. * Used by the VGA terminal to provide interactive login sessions.
  9. */
  10. #include <stdlib.h>
  11. #include <unistd.h>
  12. #include <sys/wait.h>
  13. int main(int argc, char * argv[]) {
  14. while (1) {
  15. pid_t f = fork();
  16. if (!f) {
  17. char * args[] = {
  18. "login",
  19. NULL
  20. };
  21. execvp(args[0], args);
  22. } else {
  23. int result;
  24. do {
  25. result = waitpid(f, NULL, 0);
  26. } while (result < 0);
  27. }
  28. }
  29. return 1;
  30. }