spawn.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*-
  2. * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. *
  14. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  15. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  17. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  18. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  19. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  20. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  21. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  22. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  23. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  24. * SUCH DAMAGE.
  25. */
  26. #ifndef _SPAWN_H_
  27. #define _SPAWN_H_
  28. #include <_ansi.h>
  29. #include <sys/cdefs.h>
  30. #include <sys/types.h>
  31. #include <sys/_types.h>
  32. #define __need_sigset_t
  33. #include <signal.h>
  34. struct sched_param;
  35. typedef struct __posix_spawnattr *posix_spawnattr_t;
  36. typedef struct __posix_spawn_file_actions *posix_spawn_file_actions_t;
  37. #define POSIX_SPAWN_RESETIDS 0x01
  38. #define POSIX_SPAWN_SETPGROUP 0x02
  39. #define POSIX_SPAWN_SETSCHEDPARAM 0x04
  40. #define POSIX_SPAWN_SETSCHEDULER 0x08
  41. #define POSIX_SPAWN_SETSIGDEF 0x10
  42. #define POSIX_SPAWN_SETSIGMASK 0x20
  43. _BEGIN_STD_C
  44. /*
  45. * Spawn routines
  46. *
  47. * XXX both arrays should be __restrict, but this does not work when GCC
  48. * is invoked with -std=c99.
  49. */
  50. int _EXFUN(posix_spawn, (pid_t * __restrict, const char * __restrict,
  51. const posix_spawn_file_actions_t *, const posix_spawnattr_t * __restrict,
  52. char * const [], char * const [])
  53. );
  54. int _EXFUN(posix_spawnp, (pid_t * __restrict, const char * __restrict,
  55. const posix_spawn_file_actions_t *, const posix_spawnattr_t * __restrict,
  56. char * const [], char * const [])
  57. );
  58. /*
  59. * File descriptor actions
  60. */
  61. int _EXFUN(posix_spawn_file_actions_init, (posix_spawn_file_actions_t *));
  62. int _EXFUN(posix_spawn_file_actions_destroy, (posix_spawn_file_actions_t *));
  63. int _EXFUN(posix_spawn_file_actions_addopen,
  64. (posix_spawn_file_actions_t * __restrict, int, const char * __restrict, int, mode_t)
  65. );
  66. int _EXFUN(posix_spawn_file_actions_adddup2,
  67. (posix_spawn_file_actions_t *, int, int)
  68. );
  69. int _EXFUN(posix_spawn_file_actions_addclose,
  70. (posix_spawn_file_actions_t *, int)
  71. );
  72. /*
  73. * Spawn attributes
  74. */
  75. int _EXFUN(posix_spawnattr_init, (posix_spawnattr_t *));
  76. int _EXFUN(posix_spawnattr_destroy, (posix_spawnattr_t *));
  77. int _EXFUN(posix_spawnattr_getflags,
  78. (const posix_spawnattr_t * __restrict, short * __restrict)
  79. );
  80. int _EXFUN(posix_spawnattr_getpgroup,
  81. (const posix_spawnattr_t * __restrict, pid_t * __restrict));
  82. int _EXFUN(posix_spawnattr_getschedparam,
  83. (const posix_spawnattr_t * __restrict, struct sched_param * __restrict)
  84. );
  85. int _EXFUN(posix_spawnattr_getschedpolicy,
  86. (const posix_spawnattr_t * __restrict, int * __restrict)
  87. );
  88. int _EXFUN(posix_spawnattr_getsigdefault,
  89. (const posix_spawnattr_t * __restrict, sigset_t * __restrict)
  90. );
  91. int _EXFUN(posix_spawnattr_getsigmask,
  92. (const posix_spawnattr_t * __restrict, sigset_t * __restrict)
  93. );
  94. int _EXFUN(posix_spawnattr_setflags, (posix_spawnattr_t *, short));
  95. int _EXFUN(posix_spawnattr_setpgroup, (posix_spawnattr_t *, pid_t));
  96. int _EXFUN(posix_spawnattr_setschedparam,
  97. (posix_spawnattr_t * __restrict, const struct sched_param * __restrict)
  98. );
  99. int _EXFUN(posix_spawnattr_setschedpolicy, (posix_spawnattr_t *, int));
  100. int _EXFUN(posix_spawnattr_setsigdefault,
  101. (posix_spawnattr_t * __restrict, const sigset_t * __restrict)
  102. );
  103. int _EXFUN(posix_spawnattr_setsigmask,
  104. (posix_spawnattr_t * __restrict, const sigset_t * __restrict)
  105. );
  106. _END_STD_C
  107. #endif /* !_SPAWN_H_ */