control.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* shttpd - functions for control threads
  2. Copyright (C) 2018 Ariadne Devos
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. #ifndef _sHT_CONTROL_H
  14. #define _sHT_CONTROL_H
  15. struct sHT_node
  16. {
  17. union {
  18. /* Only for killing misbehaving processes */
  19. int pid_err;
  20. /* Only for sHT_start_worker */
  21. int worker_fd_err;
  22. };
  23. /* Our end of it. A non-blocking SOCK_SEQPACKET, UNIX domain socket. */
  24. int controlfd;
  25. };
  26. /* errno values vary by architecture */
  27. enum sHT_node_errno
  28. {
  29. sHT_NODE_OTHER = 0,
  30. sHT_NODE_EINVAL,
  31. sHT_NODE_EMFILE,
  32. sHT_NODE_ENFILE,
  33. sHT_NODE_EAGAIN,
  34. sHT_NODE_ENOMEM,
  35. sHT_NODE_EPERM,
  36. };
  37. /* Possible error values:
  38. -EINVAL (bug)
  39. -EMFILE (process file descriptor limit)
  40. -ENFILE (process file descriptor limit)
  41. -EAGAIN (too many processes)
  42. -ENOMEM (lack of kernel memory)
  43. -EPERM (not allowed, configuration bug)
  44. Others that are not listed in the man pages
  45. */
  46. struct sHT_node
  47. sHT_start_worker(int workerfd);
  48. #endif