wait.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /****************************************************************************
  2. * include/sys/wait.h
  3. *
  4. * Licensed to the Apache Software Foundation (ASF) under one or more
  5. * contributor license agreements. See the NOTICE file distributed with
  6. * this work for additional information regarding copyright ownership. The
  7. * ASF licenses this file to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance with the
  9. * License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. * License for the specific language governing permissions and limitations
  17. * under the License.
  18. *
  19. ****************************************************************************/
  20. #ifndef __INCLUDE_SYS_WAIT_H
  21. #define __INCLUDE_SYS_WAIT_H
  22. /****************************************************************************
  23. * Included Files
  24. ****************************************************************************/
  25. #include <sys/types.h>
  26. #include <signal.h>
  27. #ifdef CONFIG_SCHED_WAITPID
  28. /****************************************************************************
  29. * Pre-processor Definitions
  30. ****************************************************************************/
  31. /* The following are provided for analysis of returned status values.
  32. * Encoded is as follows as 2 bytes of _info(MS) then two bytes of code (LS).
  33. * Code:
  34. * 0 - Child has exited, info is the exit code.
  35. * Other values - Not implemented
  36. */
  37. #define WEXITSTATUS(s) (((s) >> 8) & 0xff) /* Return exit status */
  38. #define WIFEXITED(s) (((s) & 0xff) == 0) /* True: Child exited normally */
  39. #define WIFCONTINUED(s) (false) /* True: Child has been continued */
  40. #define WIFSIGNALED(s) (false) /* True: Child exited due to uncaught signal */
  41. #define WIFSTOPPED(s) (false) /* True: Child is currently stopped */
  42. #define WSTOPSIG(s) (false) /* Return signal number that caused process to stop */
  43. #define WTERMSIG(s) (false) /* Return signal number that caused process to terminate */
  44. /* The following symbolic constants are possible values for the options
  45. * argument to waitpid() (1) and/or waitid() (2),
  46. */
  47. #define WCONTINUED (1 << 0) /* Status for child that has been continued (1)(2) */
  48. #define WNOHANG (1 << 1) /* Do not wait if status not available (1) (2) */
  49. #define WUNTRACED (1 << 2) /* Report status of stopped child process (1) */
  50. #define WEXITED (1 << 3) /* Wait for processes that have exited (2) */
  51. #define WSTOPPED (1 << 4) /* Status for child stopped on signal (2) */
  52. #define WNOWAIT (1 << 5) /* Keep the process in a waitable state (2) */
  53. #define WCLAIMED (1 << 7) /* Non-standard (For internal OS use only) */
  54. /****************************************************************************
  55. * Public Type Definitions
  56. ****************************************************************************/
  57. #ifndef __ASSEMBLY__
  58. enum idtype_e
  59. {
  60. P_PID = 1,
  61. P_PGID = 2,
  62. P_ALL = 3
  63. };
  64. typedef enum idtype_e idtype_t;
  65. /****************************************************************************
  66. * Public Function Prototypes
  67. ****************************************************************************/
  68. #undef EXTERN
  69. #if defined(__cplusplus)
  70. #define EXTERN extern "C"
  71. extern "C"
  72. {
  73. #else
  74. #define EXTERN extern
  75. #endif
  76. pid_t wait(FAR int *stat_loc);
  77. int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options);
  78. pid_t waitpid(pid_t pid, FAR int *stat_loc, int options);
  79. #undef EXTERN
  80. #if defined(__cplusplus)
  81. }
  82. #endif
  83. #endif /* __ASSEMBLY__ */
  84. #endif /* CONFIG_SCHED_WAITPID */
  85. #endif /* __INCLUDE_SYS_WAIT_H */