unistd.h 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017
  1. /* Copyright (C) 1991-1999, 2000 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Library General Public License as
  5. published by the Free Software Foundation; either version 2 of the
  6. License, or (at your option) any later version.
  7. The GNU C Library 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 GNU
  10. Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public
  12. License along with the GNU C Library; see the file COPYING.LIB. If not,
  13. write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. Boston, MA 02111-1307, USA. */
  15. /*
  16. * POSIX Standard: 2.10 Symbolic Constants <unistd.h>
  17. */
  18. #ifndef _UNISTD_H
  19. #define _UNISTD_H 1
  20. #include <errno.h>
  21. #include <features.h>
  22. #include <sys/types.h>
  23. #include <asm/unistd.h>
  24. __BEGIN_DECLS
  25. /* These may be used to determine what facilities are present at compile time.
  26. Their values can be obtained at run time from `sysconf'. */
  27. /* POSIX Standard approved as ISO/IEC 9945-1 as of August, 1988 and
  28. extended by POSIX-1b (aka POSIX-4) and POSIX-1c (aka POSIX threads). */
  29. #define _POSIX_VERSION 199506L
  30. /* These are not #ifdef __USE_POSIX2 because they are
  31. in the theoretically application-owned namespace. */
  32. /* POSIX Standard approved as ISO/IEC 9945-2 as of December, 1993. */
  33. #define _POSIX2_C_VERSION 199209L
  34. /* The utilities on GNU systems also correspond to this version. */
  35. #define _POSIX2_VERSION 199209L
  36. /* If defined, the implementation supports the
  37. C Language Bindings Option. */
  38. #define _POSIX2_C_BIND 1
  39. /* If defined, the implementation supports the
  40. C Language Development Utilities Option. */
  41. #define _POSIX2_C_DEV 1
  42. /* If defined, the implementation supports the
  43. Software Development Utilities Option. */
  44. #define _POSIX2_SW_DEV 1
  45. /* If defined, the implementation supports the
  46. creation of locales with the localedef utility. */
  47. #define _POSIX2_LOCALEDEF 1
  48. /* X/Open version number to which the library conforms. It is selectable. */
  49. #ifdef __USE_UNIX98
  50. # define _XOPEN_VERSION 500
  51. #else
  52. # define _XOPEN_VERSION 4
  53. #endif
  54. /* Commands and utilities from XPG4 are available. */
  55. #define _XOPEN_XCU_VERSION 4
  56. /* We are compatible with the old published standards as well. */
  57. #define _XOPEN_XPG2 1
  58. #define _XOPEN_XPG3 1
  59. #define _XOPEN_XPG4 1
  60. /* The X/Open Unix extensions are available. */
  61. #define _XOPEN_UNIX 1
  62. /* Encryption is present. */
  63. #define _XOPEN_CRYPT 1
  64. /* The enhanced internationalization capabilities according to XPG4.2
  65. are present. */
  66. #define _XOPEN_ENH_I18N 1
  67. /* The legacy interfaces are also available. */
  68. #define _XOPEN_LEGACY 1
  69. /* Get values of POSIX options:
  70. If these symbols are defined, the corresponding features are
  71. always available. If not, they may be available sometimes.
  72. The current values can be obtained with `sysconf'.
  73. _POSIX_JOB_CONTROL Job control is supported.
  74. _POSIX_SAVED_IDS Processes have a saved set-user-ID
  75. and a saved set-group-ID.
  76. _POSIX_REALTIME_SIGNALS Real-time, queued signals are supported.
  77. _POSIX_PRIORITY_SCHEDULING Priority scheduling is supported.
  78. _POSIX_TIMERS POSIX.4 clocks and timers are supported.
  79. _POSIX_ASYNCHRONOUS_IO Asynchronous I/O is supported.
  80. _POSIX_PRIORITIZED_IO Prioritized asynchronous I/O is supported.
  81. _POSIX_SYNCHRONIZED_IO Synchronizing file data is supported.
  82. _POSIX_FSYNC The fsync function is present.
  83. _POSIX_MAPPED_FILES Mapping of files to memory is supported.
  84. _POSIX_MEMLOCK Locking of all memory is supported.
  85. _POSIX_MEMLOCK_RANGE Locking of ranges of memory is supported.
  86. _POSIX_MEMORY_PROTECTION Setting of memory protections is supported.
  87. _POSIX_MESSAGE_PASSING POSIX.4 message queues are supported.
  88. _POSIX_SEMAPHORES POSIX.4 counting semaphores are supported.
  89. _POSIX_SHARED_MEMORY_OBJECTS POSIX.4 shared memory objects are supported.
  90. _POSIX_THREADS POSIX.1c pthreads are supported.
  91. _POSIX_THREAD_ATTR_STACKADDR Thread stack address attribute option supported.
  92. _POSIX_THREAD_ATTR_STACKSIZE Thread stack size attribute option supported.
  93. _POSIX_THREAD_SAFE_FUNCTIONS Thread-safe functions are supported.
  94. _POSIX_THREAD_PRIORITY_SCHEDULING
  95. POSIX.1c thread execution scheduling supported.
  96. _POSIX_THREAD_PRIO_INHERIT Thread priority inheritance option supported.
  97. _POSIX_THREAD_PRIO_PROTECT Thread priority protection option supported.
  98. _POSIX_THREAD_PROCESS_SHARED Process-shared synchronization supported.
  99. _POSIX_PII Protocol-independent interfaces are supported.
  100. _POSIX_PII_XTI XTI protocol-indep. interfaces are supported.
  101. _POSIX_PII_SOCKET Socket protocol-indep. interfaces are supported.
  102. _POSIX_PII_INTERNET Internet family of protocols supported.
  103. _POSIX_PII_INTERNET_STREAM Connection-mode Internet protocol supported.
  104. _POSIX_PII_INTERNET_DGRAM Connectionless Internet protocol supported.
  105. _POSIX_PII_OSI ISO/OSI family of protocols supported.
  106. _POSIX_PII_OSI_COTS Connection-mode ISO/OSI service supported.
  107. _POSIX_PII_OSI_CLTS Connectionless ISO/OSI service supported.
  108. _POSIX_POLL Implementation supports `poll' function.
  109. _POSIX_SELECT Implementation supports `select' and `pselect'.
  110. _XOPEN_REALTIME X/Open realtime support is available.
  111. _XOPEN_REALTIME_THREADS X/Open realtime thread support is available.
  112. _XOPEN_SHM Shared memory interface according to XPG4.2.
  113. _XBS5_ILP32_OFF32 Implementation provides environment with 32-bit
  114. int, long, pointer, and off_t types.
  115. _XBS5_ILP32_OFFBIG Implementation provides environment with 32-bit
  116. int, long, and pointer and off_t with at least
  117. 64 bits.
  118. _XBS5_LP64_OFF64 Implementation provides environment with 32-bit
  119. int, and 64-bit long, pointer, and off_t types.
  120. _XBS5_LPBIG_OFFBIG Implementation provides environment with at
  121. least 32 bits int and long, pointer, and off_t
  122. with at least 64 bits.
  123. If any of these symbols is defined as -1, the corresponding option is not
  124. true for any file. If any is defined as other than -1, the corresponding
  125. option is true for all files. If a symbol is not defined at all, the value
  126. for a specific file can be obtained from `pathconf' and `fpathconf'.
  127. _POSIX_CHOWN_RESTRICTED Only the super user can use `chown' to change
  128. the owner of a file. `chown' can only be used
  129. to change the group ID of a file to a group of
  130. which the calling process is a member.
  131. _POSIX_NO_TRUNC Pathname components longer than
  132. NAME_MAX generate an error.
  133. _POSIX_VDISABLE If defined, if the value of an element of the
  134. `c_cc' member of `struct termios' is
  135. _POSIX_VDISABLE, no character will have the
  136. effect associated with that element.
  137. _POSIX_SYNC_IO Synchronous I/O may be performed.
  138. _POSIX_ASYNC_IO Asynchronous I/O may be performed.
  139. _POSIX_PRIO_IO Prioritized Asynchronous I/O may be performed.
  140. Support for the Large File Support interface is not generally available.
  141. If it is available the following constants are defined to one.
  142. _LFS64_LARGEFILE Low-level I/O supports large files.
  143. _LFS64_STDIO Standard I/O supports large files.
  144. */
  145. #include <bits/posix_opt.h>
  146. /* At this time, we don't do pthreads... Sorry... */
  147. #undef _POSIX_THREADS
  148. /* Get the environment definitions from Unix98. */
  149. #ifdef __USE_UNIX98
  150. # include <bits/environments.h>
  151. #endif
  152. /* Standard file descriptors. */
  153. #define STDIN_FILENO 0 /* Standard input. */
  154. #define STDOUT_FILENO 1 /* Standard output. */
  155. #define STDERR_FILENO 2 /* Standard error output. */
  156. /* All functions that are not declared anywhere else. */
  157. #include <bits/types.h>
  158. #ifndef ssize_t
  159. typedef __ssize_t ssize_t;
  160. # define ssize_t ssize_t
  161. #endif
  162. #define __need_size_t
  163. #define __need_NULL
  164. #include <stddef.h>
  165. #ifdef __USE_XOPEN
  166. /* The Single Unix specification says that some more types are
  167. available here. */
  168. # ifndef gid_t
  169. typedef __gid_t gid_t;
  170. # define gid_t gid_t
  171. # endif
  172. # ifndef uid_t
  173. typedef __uid_t uid_t;
  174. # define uid_t uid_t
  175. # endif
  176. # ifndef off_t
  177. # ifndef __USE_FILE_OFFSET64
  178. typedef __off_t off_t;
  179. # else
  180. typedef __off64_t off_t;
  181. # endif
  182. # define off_t off_t
  183. # endif
  184. # if defined __USE_LARGEFILE64 && !defined off64_t
  185. typedef __off64_t off64_t;
  186. # define off64_t off64_t
  187. # endif
  188. # ifndef pid_t
  189. typedef __pid_t pid_t;
  190. # define pid_t pid_t
  191. # endif
  192. #endif /* X/Open */
  193. #ifdef __USE_UNIX98
  194. # ifndef intptr_t
  195. typedef __intptr_t intptr_t;
  196. # define intptr_t intptr_t
  197. # endif
  198. #endif /* Unix98 */
  199. /* Values for the second argument to access.
  200. These may be OR'd together. */
  201. #define R_OK 4 /* Test for read permission. */
  202. #define W_OK 2 /* Test for write permission. */
  203. #define X_OK 1 /* Test for execute permission. */
  204. #define F_OK 0 /* Test for existence. */
  205. /* Test for access to NAME using the real UID and real GID. */
  206. extern int access __P ((__const char *__name, int __type));
  207. #ifdef __USE_GNU
  208. /* Test for access to NAME using the effective UID and GID
  209. (as normal file operations use). */
  210. extern int euidaccess __P ((__const char *__name, int __type));
  211. #endif
  212. /* Values for the WHENCE argument to lseek. */
  213. #ifndef _STDIO_H /* <stdio.h> has the same definitions. */
  214. # define SEEK_SET 0 /* Seek from beginning of file. */
  215. # define SEEK_CUR 1 /* Seek from current position. */
  216. # define SEEK_END 2 /* Seek from end of file. */
  217. #endif
  218. #if defined __USE_BSD && !defined L_SET
  219. /* Old BSD names for the same constants; just for compatibility. */
  220. # define L_SET SEEK_SET
  221. # define L_INCR SEEK_CUR
  222. # define L_XTND SEEK_END
  223. #endif
  224. /* Move FD's file position to OFFSET bytes from the
  225. beginning of the file (if WHENCE is SEEK_SET),
  226. the current position (if WHENCE is SEEK_CUR),
  227. or the end of the file (if WHENCE is SEEK_END).
  228. Return the new file position. */
  229. extern __off_t __lseek __P ((int __fd, __off_t __offset, int __whence));
  230. #ifndef __USE_FILE_OFFSET64
  231. extern __off_t lseek __P ((int __fd, __off_t __offset, int __whence));
  232. #else
  233. # ifdef __REDIRECT
  234. extern __off64_t __REDIRECT (lseek,
  235. __P ((int __fd, __off64_t __offset,
  236. int __whence)),
  237. lseek64);
  238. # else
  239. # define lseek lseek64
  240. # endif
  241. #endif
  242. #ifdef __USE_LARGEFILE64
  243. extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
  244. #endif
  245. /* Close the file descriptor FD. */
  246. extern int __close __P ((int __fd));
  247. extern int close __P ((int __fd));
  248. /* Read NBYTES into BUF from FD. Return the
  249. number read, -1 for errors or 0 for EOF. */
  250. extern ssize_t __read __P ((int __fd, __ptr_t __buf, size_t __nbytes));
  251. extern ssize_t read __P ((int __fd, __ptr_t __buf, size_t __nbytes));
  252. /* Write N bytes of BUF to FD. Return the number written, or -1. */
  253. extern ssize_t __write __P ((int __fd, __const __ptr_t __buf, size_t __n));
  254. extern ssize_t write __P ((int __fd, __const __ptr_t __buf, size_t __n));
  255. #ifdef __USE_UNIX98
  256. /* Read NBYTES into BUF from FD at the given position OFFSET without
  257. changing the file pointer. Return the number read, -1 for errors
  258. or 0 for EOF. */
  259. extern ssize_t __pread64 __P ((int __fd, __ptr_t __buf, size_t __nbytes,
  260. __off64_t __offset));
  261. /* Write N bytes of BUF to FD at the given position OFFSET without
  262. changing the file pointer. Return the number written, or -1. */
  263. extern ssize_t __pwrite64 __P ((int __fd, __const __ptr_t __buf, size_t __n,
  264. __off64_t __offset));
  265. # ifndef __USE_FILE_OFFSET64
  266. extern ssize_t pread __P ((int __fd, __ptr_t __buf, size_t __nbytes,
  267. __off_t __offset));
  268. extern ssize_t pwrite __P ((int __fd, __const __ptr_t __buf, size_t __n,
  269. __off_t __offset));
  270. # else
  271. # ifdef __REDIRECT
  272. extern ssize_t __REDIRECT (pread, __P ((int __fd, __ptr_t __buf,
  273. size_t __nbytes,__off64_t __offset)),
  274. pread64);
  275. extern ssize_t __REDIRECT (pwrite, __P ((int __fd, __const __ptr_t __buf,
  276. size_t __nbytes, __off64_t __offset)),
  277. pwrite64);
  278. # else
  279. # define pread pread64
  280. # define pwrite pwrite64
  281. # endif
  282. # endif
  283. # ifdef __USE_LARGEFILE64
  284. extern ssize_t pread64 __P ((int __fd, __ptr_t __buf, size_t __nbytes,
  285. __off64_t __offset));
  286. extern ssize_t pwrite64 __P ((int __fd, __const __ptr_t __buf, size_t __n,
  287. __off64_t __offset));
  288. # endif
  289. #endif
  290. /* Create a one-way communication channel (pipe).
  291. If successful, two file descriptors are stored in PIPEDES;
  292. bytes written on PIPEDES[1] can be read from PIPEDES[0].
  293. Returns 0 if successful, -1 if not. */
  294. extern int pipe __P ((int __pipedes[2]));
  295. /* Schedule an alarm. In SECONDS seconds, the process will get a SIGALRM.
  296. If SECONDS is zero, any currently scheduled alarm will be cancelled.
  297. The function returns the number of seconds remaining until the last
  298. alarm scheduled would have signaled, or zero if there wasn't one.
  299. There is no return value to indicate an error, but you can set `errno'
  300. to 0 and check its value after calling `alarm', and this might tell you.
  301. The signal may come late due to processor scheduling. */
  302. extern unsigned int alarm __P ((unsigned int __seconds));
  303. /* Make the process sleep for SECONDS seconds, or until a signal arrives
  304. and is not ignored. The function returns the number of seconds less
  305. than SECONDS which it actually slept (thus zero if it slept the full time).
  306. If a signal handler does a `longjmp' or modifies the handling of the
  307. SIGALRM signal while inside `sleep' call, the handling of the SIGALRM
  308. signal afterwards is undefined. There is no return value to indicate
  309. error, but if `sleep' returns SECONDS, it probably didn't work. */
  310. extern unsigned int sleep __P ((unsigned int __seconds));
  311. #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
  312. /* Set an alarm to go off (generating a SIGALRM signal) in VALUE
  313. microseconds. If INTERVAL is nonzero, when the alarm goes off, the
  314. timer is reset to go off every INTERVAL microseconds thereafter.
  315. Returns the number of microseconds remaining before the alarm. */
  316. extern unsigned int ualarm __P ((unsigned int __value,
  317. unsigned int __interval));
  318. /* Sleep USECONDS microseconds, or until a signal arrives that is not blocked
  319. or ignored. */
  320. extern void usleep __P ((unsigned int __useconds));
  321. #endif
  322. /* Suspend the process until a signal arrives.
  323. This always returns -1 and sets `errno' to EINTR. */
  324. extern int pause __P ((void));
  325. /* Change the owner and group of FILE. */
  326. extern int chown __P ((__const char *__file, __uid_t __owner,
  327. __gid_t __group));
  328. #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
  329. /* Change the owner and group of the file that FD is open on. */
  330. extern int fchown __P ((int __fd, __uid_t __owner, __gid_t __group));
  331. /* Change owner and group of FILE, if it is a symbolic
  332. link the ownership of the symbolic link is changed. */
  333. extern int lchown __P ((__const char *__file, __uid_t __owner,
  334. __gid_t __group));
  335. #endif /* Use BSD || X/Open Unix. */
  336. /* Change the process's working directory to PATH. */
  337. extern int chdir __P ((__const char *__path));
  338. #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
  339. /* Change the process's working directory to the one FD is open on. */
  340. extern int fchdir __P ((int __fd));
  341. #endif
  342. /* Get the pathname of the current working directory,
  343. and put it in SIZE bytes of BUF. Returns NULL if the
  344. directory couldn't be determined or SIZE was too small.
  345. If successful, returns BUF. In GNU, if BUF is NULL,
  346. an array is allocated with `malloc'; the array is SIZE
  347. bytes long, unless SIZE == 0, in which case it is as
  348. big as necessary. */
  349. extern char *getcwd __P ((char *__buf, size_t __size));
  350. #ifdef __USE_GNU
  351. /* Return a malloc'd string containing the current directory name.
  352. If the environment variable `PWD' is set, and its value is correct,
  353. that value is used. */
  354. extern char *get_current_dir_name __P ((void));
  355. #endif
  356. #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
  357. /* Put the absolute pathname of the current working directory in BUF.
  358. If successful, return BUF. If not, put an error message in
  359. BUF and return NULL. BUF should be at least PATH_MAX bytes long. */
  360. extern char *getwd __P ((char *__buf));
  361. #endif
  362. /* Duplicate FD, returning a new file descriptor on the same file. */
  363. extern int dup __P ((int __fd));
  364. /* Duplicate FD to FD2, closing FD2 and making it open on the same file. */
  365. extern int dup2 __P ((int __fd, int __fd2));
  366. /* NULL-terminated array of "NAME=VALUE" environment variables. */
  367. extern char **__environ;
  368. extern char **environ;
  369. /* Replace the current process, executing PATH with arguments ARGV and
  370. environment ENVP. ARGV and ENVP are terminated by NULL pointers. */
  371. extern int execve __P ((__const char *__path, char *__const __argv[],
  372. char *__const __envp[]));
  373. #ifdef __USE_GNU
  374. /* Execute the file FD refers to, overlaying the running program image.
  375. ARGV and ENVP are passed to the new program, as for `execve'. */
  376. extern int fexecve __P ((int __fd,
  377. char *__const __argv[], char *__const __envp[]));
  378. #endif
  379. /* Execute PATH with arguments ARGV and environment from `environ'. */
  380. extern int execv __P ((__const char *__path, char *__const __argv[]));
  381. /* Execute PATH with all arguments after PATH until a NULL pointer,
  382. and the argument after that for environment. */
  383. extern int execle __P ((__const char *__path, __const char *__arg, ...));
  384. /* Execute PATH with all arguments after PATH until
  385. a NULL pointer and environment from `environ'. */
  386. extern int execl __P ((__const char *__path, __const char *__arg, ...));
  387. /* Execute FILE, searching in the `PATH' environment variable if it contains
  388. no slashes, with arguments ARGV and environment from `environ'. */
  389. extern int execvp __P ((__const char *__file, char *__const __argv[]));
  390. /* Execute FILE, searching in the `PATH' environment variable if
  391. it contains no slashes, with all arguments after FILE until a
  392. NULL pointer and environment from `environ'. */
  393. extern int execlp __P ((__const char *__file, __const char *__arg, ...));
  394. #if defined __USE_MISC || defined __USE_XOPEN
  395. /* Add INC to priority of the current process. */
  396. extern int nice __P ((int __inc));
  397. #endif
  398. /* Terminate program execution with the low-order 8 bits of STATUS. */
  399. extern void _exit __PMT ((int __status)) __attribute__ ((__noreturn__));
  400. /* Get the `_PC_*' symbols for the NAME argument to `pathconf' and `fpathconf';
  401. the `_SC_*' symbols for the NAME argument to `sysconf';
  402. and the `_CS_*' symbols for the NAME argument to `confstr'. */
  403. #include <bits/confname.h>
  404. /* Get file-specific configuration information about PATH. */
  405. extern long int pathconf __P ((__const char *__path, int __name));
  406. /* Get file-specific configuration about descriptor FD. */
  407. extern long int fpathconf __P ((int __fd, int __name));
  408. /* Get the value of the system variable NAME. */
  409. extern long int sysconf __P ((int __name));
  410. #ifdef __USE_POSIX2
  411. /* Get the value of the string-valued system variable NAME. */
  412. extern size_t confstr __P ((int __name, char *__buf, size_t __len));
  413. #endif
  414. /* Get the process ID of the calling process. */
  415. extern __pid_t __getpid __P ((void));
  416. extern __pid_t getpid __P ((void));
  417. /* Get the process ID of the calling process's parent. */
  418. extern __pid_t getppid __P ((void));
  419. /* Get the process group ID of the calling process.
  420. This function is different on old BSD. */
  421. #ifndef __FAVOR_BSD
  422. extern __pid_t getpgrp __P ((void));
  423. #else
  424. # ifdef __REDIRECT
  425. extern __pid_t __REDIRECT (getpgrp, __P ((__pid_t __pid)), __getpgid);
  426. # else
  427. # define getpgrp __getpgid
  428. # endif
  429. #endif
  430. /* Get the process group ID of process PID. */
  431. extern __pid_t __getpgid __P ((__pid_t __pid));
  432. #ifdef __USE_XOPEN_EXTENDED
  433. extern __pid_t getpgid __P ((__pid_t __pid));
  434. #endif
  435. /* Set the process group ID of the process matching PID to PGID.
  436. If PID is zero, the current process's process group ID is set.
  437. If PGID is zero, the process ID of the process is used. */
  438. extern int __setpgid __P ((__pid_t __pid, __pid_t __pgid));
  439. extern int setpgid __P ((__pid_t __pid, __pid_t __pgid));
  440. #if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
  441. /* Both System V and BSD have `setpgrp' functions, but with different
  442. calling conventions. The BSD function is the same as POSIX.1 `setpgid'
  443. (above). The System V function takes no arguments and puts the calling
  444. process in its on group like `setpgid (0, 0)'.
  445. New programs should always use `setpgid' instead.
  446. The default in GNU is to provide the System V function. The BSD
  447. function is available under -D_BSD_SOURCE. */
  448. # ifndef __FAVOR_BSD
  449. /* Set the process group ID of the calling process to its own PID.
  450. This is exactly the same as `setpgid (0, 0)'. */
  451. extern int setpgrp __P ((void));
  452. # else
  453. /* Another name for `setpgid' (above). */
  454. # ifdef __REDIRECT
  455. extern int __REDIRECT (setpgrp, __P ((__pid_t __pid, __pid_t __pgrp)),
  456. setpgid);
  457. # else
  458. # define setpgrp setpgid
  459. # endif
  460. # endif /* Favor BSD. */
  461. #endif /* Use SVID or BSD. */
  462. /* Create a new session with the calling process as its leader.
  463. The process group IDs of the session and the calling process
  464. are set to the process ID of the calling process, which is returned. */
  465. extern __pid_t setsid __P ((void));
  466. #ifdef __USE_XOPEN_EXTENDED
  467. /* Return the session ID of the given process. */
  468. extern __pid_t getsid __P ((__pid_t __pid));
  469. #endif
  470. /* Get the real user ID of the calling process. */
  471. extern __uid_t getuid __P ((void));
  472. /* Get the effective user ID of the calling process. */
  473. extern __uid_t geteuid __P ((void));
  474. /* Get the real group ID of the calling process. */
  475. extern __gid_t getgid __P ((void));
  476. /* Get the effective group ID of the calling process. */
  477. extern __gid_t getegid __P ((void));
  478. /* If SIZE is zero, return the number of supplementary groups
  479. the calling process is in. Otherwise, fill in the group IDs
  480. of its supplementary groups in LIST and return the number written. */
  481. extern int getgroups __P ((int __size, __gid_t __list[]));
  482. #ifdef __USE_GNU
  483. /* Return nonzero iff the calling process is in group GID. */
  484. extern int group_member __P ((__gid_t __gid));
  485. #endif
  486. /* Set the user ID of the calling process to UID.
  487. If the calling process is the super-user, set the real
  488. and effective user IDs, and the saved set-user-ID to UID;
  489. if not, the effective user ID is set to UID. */
  490. extern int setuid __P ((__uid_t __uid));
  491. #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
  492. /* Set the real user ID of the calling process to RUID,
  493. and the effective user ID of the calling process to EUID. */
  494. extern int setreuid __P ((__uid_t __ruid, __uid_t __euid));
  495. #endif
  496. #ifdef __USE_BSD
  497. /* Set the effective user ID of the calling process to UID. */
  498. extern int seteuid __P ((__uid_t __uid));
  499. #endif /* Use BSD. */
  500. /* Set the group ID of the calling process to GID.
  501. If the calling process is the super-user, set the real
  502. and effective group IDs, and the saved set-group-ID to GID;
  503. if not, the effective group ID is set to GID. */
  504. extern int setgid __P ((__gid_t __gid));
  505. #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
  506. /* Set the real group ID of the calling process to RGID,
  507. and the effective group ID of the calling process to EGID. */
  508. extern int setregid __P ((__gid_t __rgid, __gid_t __egid));
  509. #endif
  510. #ifdef __USE_BSD
  511. /* Set the effective group ID of the calling process to GID. */
  512. extern int setegid __P ((__gid_t __gid));
  513. #endif /* Use BSD. */
  514. /* Clone the calling process, creating an exact copy.
  515. Return -1 for errors, 0 to the new process,
  516. and the process ID of the new process to the old process. */
  517. #ifdef __UCLIBC_HAS_MMU__
  518. extern __pid_t fork __P ((void));
  519. #else
  520. #define fork fork_not_available_on_mmuless_systems
  521. #endif
  522. #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
  523. /* Clone the calling process, but without copying the whole address space.
  524. The calling process is suspended until the new process exits or is
  525. replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
  526. and the process ID of the new process to the old process. */
  527. extern __pid_t vfork __P ((void));
  528. #endif /* Use BSD. */
  529. /* Return the pathname of the terminal FD is open on, or NULL on errors.
  530. The returned storage is good only until the next call to this function. */
  531. extern char *ttyname __P ((int __fd));
  532. /* Store at most BUFLEN characters of the pathname of the terminal FD is
  533. open on in BUF. Return 0 on success, otherwise an error number. */
  534. extern int ttyname_r __P ((int __fd, char *__buf, size_t __buflen));
  535. /* Return 1 if FD is a valid descriptor associated
  536. with a terminal, zero if not. */
  537. extern int isatty __P ((int __fd));
  538. #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
  539. /* Return the index into the active-logins file (utmp) for
  540. the controlling terminal. */
  541. extern int ttyslot __P ((void));
  542. #endif
  543. /* Make a link to FROM named TO. */
  544. extern int link __P ((__const char *__from, __const char *__to));
  545. #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
  546. /* Make a symbolic link to FROM named TO. */
  547. extern int symlink __P ((__const char *__from, __const char *__to));
  548. /* Read the contents of the symbolic link PATH into no more than
  549. LEN bytes of BUF. The contents are not null-terminated.
  550. Returns the number of characters read, or -1 for errors. */
  551. extern int readlink __P ((__const char *__path, char *__buf, size_t __len));
  552. #endif /* Use BSD. */
  553. /* Remove the link NAME. */
  554. extern int unlink __P ((__const char *__name));
  555. /* Remove the directory PATH. */
  556. extern int rmdir __P ((__const char *__path));
  557. /* Return the foreground process group ID of FD. */
  558. extern __pid_t tcgetpgrp __P ((int __fd));
  559. /* Set the foreground process group ID of FD set PGRP_ID. */
  560. extern int tcsetpgrp __P ((int __fd, __pid_t __pgrp_id));
  561. /* Return the login name of the user. */
  562. extern char *getlogin __P ((void));
  563. #ifdef __USE_REENTRANT
  564. /* Return at most NAME_LEN characters of the login name of the user in NAME.
  565. If it cannot be determined or some other error occurred, return the error
  566. code. Otherwise return 0. */
  567. extern int getlogin_r __P ((char *__name, size_t __name_len));
  568. #endif
  569. #ifdef __USE_BSD
  570. /* Set the login name returned by `getlogin'. */
  571. extern int setlogin __P ((__const char *__name));
  572. #endif
  573. #ifdef __USE_POSIX2
  574. /* Get definitions and prototypes for functions to process the
  575. arguments in ARGV (ARGC of them, minus the program name) for
  576. options given in OPTS. */
  577. # define __need_getopt
  578. # include <getopt.h>
  579. #endif
  580. #if defined __USE_BSD || defined __USE_XOPEN
  581. /* Put the name of the current host in no more than LEN bytes of NAME.
  582. The result is null-terminated if LEN is large enough for the full
  583. name and the terminator. */
  584. extern int gethostname __P ((char *__name, size_t __len));
  585. /* Set the name of the current host to NAME, which is LEN bytes long.
  586. This call is restricted to the super-user. */
  587. extern int sethostname __P ((__const char *__name, size_t __len));
  588. /* Set the current machine's Internet number to ID.
  589. This call is restricted to the super-user. */
  590. extern int sethostid __P ((long int __id));
  591. /* Get and set the NIS (aka YP) domain name, if any.
  592. Called just like `gethostname' and `sethostname'.
  593. The NIS domain name is usually the empty string when not using NIS. */
  594. extern int getdomainname __P ((char *__name, size_t __len));
  595. extern int setdomainname __P ((__const char *__name, size_t __len));
  596. /* Make all changes done to FD actually appear on disk. */
  597. extern int fsync __P ((int __fd));
  598. /* Revoke access permissions to all processes currently communicating
  599. with the control terminal, and then send a SIGHUP signal to the process
  600. group of the control terminal. */
  601. extern int vhangup __P ((void));
  602. /* Revoke the access of all descriptors currently open on FILE. */
  603. extern int revoke __P ((__const char *__file));
  604. /* Enable statistical profiling, writing samples of the PC into at most
  605. SIZE bytes of SAMPLE_BUFFER; every processor clock tick while profiling
  606. is enabled, the system examines the user PC and increments
  607. SAMPLE_BUFFER[((PC - OFFSET) / 2) * SCALE / 65536]. If SCALE is zero,
  608. disable profiling. Returns zero on success, -1 on error. */
  609. extern int profil __P ((unsigned short int *__sample_buffer, size_t __size,
  610. size_t __offset, unsigned int __scale));
  611. /* Turn accounting on if NAME is an existing file. The system will then write
  612. a record for each process as it terminates, to this file. If NAME is NULL,
  613. turn accounting off. This call is restricted to the super-user. */
  614. extern int acct __P ((__const char *__name));
  615. /* Make PATH be the root directory (the starting point for absolute paths).
  616. This call is restricted to the super-user. */
  617. extern int chroot __P ((__const char *__path));
  618. /* Successive calls return the shells listed in `/etc/shells'. */
  619. extern char *getusershell __P ((void));
  620. extern void endusershell __P ((void)); /* Discard cached info. */
  621. extern void setusershell __P ((void)); /* Rewind and re-read the file. */
  622. /* Prompt with PROMPT and read a string from the terminal without echoing.
  623. Uses /dev/tty if possible; otherwise stderr and stdin. */
  624. extern char *getpass __P ((__const char *__prompt));
  625. /* Put the program in the background, and dissociate from the controlling
  626. terminal. If NOCHDIR is zero, do `chdir ("/")'. If NOCLOSE is zero,
  627. redirects stdin, stdout, and stderr to /dev/null. */
  628. extern int daemon __P ((int __nochdir, int __noclose));
  629. #endif /* Use BSD || X/Open. */
  630. #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
  631. /* Return the current machine's Internet number. */
  632. extern long int gethostid __P ((void));
  633. /* Make all changes done to all files actually appear on disk. */
  634. extern int sync __P ((void));
  635. /* Return the number of bytes in a page. This is the system's page size,
  636. which is not necessarily the same as the hardware page size. */
  637. extern int __getpagesize __P ((void)) __attribute__ ((__const__));
  638. extern int getpagesize __P ((void)) __attribute__ ((__const__));
  639. /* Truncate FILE to LENGTH bytes. */
  640. #ifndef __USE_FILE_OFFSET64
  641. extern int truncate __P ((__const char *__file, __off_t __length));
  642. #else
  643. # ifdef __REDIRECT
  644. extern int __REDIRECT (truncate,
  645. __P ((__const char *__file, __off64_t __length)),
  646. truncate64);
  647. # else
  648. # define truncate truncate64
  649. # endif
  650. #endif
  651. #ifdef __USE_LARGEFILE64
  652. extern int truncate64 __P ((__const char *__file, __off64_t __length));
  653. #endif
  654. /* Truncate the file FD is open on to LENGTH bytes. */
  655. extern int __ftruncate __P ((int __fd, __off_t __length));
  656. #ifndef __USE_FILE_OFFSET64
  657. extern int ftruncate __P ((int __fd, __off_t __length));
  658. #else
  659. # ifdef __REDIRECT
  660. extern int __REDIRECT (ftruncate, __P ((int __fd, __off64_t __length)),
  661. ftruncate64);
  662. # else
  663. # define ftruncate ftruncate64
  664. # endif
  665. #endif
  666. #ifdef __USE_LARGEFILE64
  667. extern int ftruncate64 __P ((int __fd, __off64_t __length));
  668. #endif
  669. /* Return the maximum number of file descriptors
  670. the current process could possibly have. */
  671. extern int getdtablesize __P ((void));
  672. #endif /* Use BSD || X/Open Unix. */
  673. #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
  674. /* Set the end of accessible data space (aka "the break") to ADDR.
  675. Returns zero on success and -1 for errors (with errno set). */
  676. extern int brk __P ((__ptr_t __addr));
  677. # define __need_ptrdiff_t
  678. # include <stddef.h>
  679. /* Increase or decrease the end of accessible data space by DELTA bytes.
  680. If successful, returns the address the previous end of data space
  681. (i.e. the beginning of the new space, if DELTA > 0);
  682. returns (void *) -1 for errors (with errno set). */
  683. #define ptrdiff_t int
  684. extern __ptr_t __sbrk __P ((ptrdiff_t __delta));
  685. extern __ptr_t sbrk __P ((ptrdiff_t __delta));
  686. #endif
  687. #ifdef __USE_MISC
  688. /* Invoke `system call' number SYSNO, passing it the remaining arguments.
  689. This is completely system-dependent, and not often useful.
  690. In Unix, `syscall' sets `errno' for all errors and most calls return -1
  691. for errors; in many systems you cannot pass arguments or get return
  692. values for all system calls (`pipe', `fork', and `getppid' typically
  693. among them).
  694. In Mach, all system calls take normal arguments and always return an
  695. error code (zero for success). */
  696. extern long int syscall __P ((long int __sysno, ...));
  697. #endif /* Use misc. */
  698. #if (defined __USE_MISC || defined __USE_XOPEN_EXTENDED) && !defined F_LOCK
  699. /* NOTE: These declarations also appear in <fcntl.h>; be sure to keep both
  700. files consistent. Some systems have them there and some here, and some
  701. software depends on the macros being defined without including both. */
  702. /* `lockf' is a simpler interface to the locking facilities of `fcntl'.
  703. LEN is always relative to the current file position.
  704. The CMD argument is one of the following. */
  705. # define F_ULOCK 0 /* Unlock a previously locked region. */
  706. # define F_LOCK 1 /* Lock a region for exclusive use. */
  707. # define F_TLOCK 2 /* Test and lock a region for exclusive use. */
  708. # define F_TEST 3 /* Test a region for other processes locks. */
  709. # ifndef __USE_FILE_OFFSET64
  710. extern int lockf __P ((int __fd, int __cmd, __off_t __len));
  711. # else
  712. # ifdef __REDIRECT
  713. extern int __REDIRECT (lockf, __P ((int __fd, int __cmd, __off64_t __len)),
  714. lockf64);
  715. # else
  716. # define lockf lockf64
  717. # endif
  718. # endif
  719. # ifdef __USE_LARGEFILE64
  720. extern int lockf64 __P ((int __fd, int __cmd, __off64_t __len));
  721. # endif
  722. #endif /* Use misc and F_LOCK not already defined. */
  723. #ifdef __USE_GNU
  724. /* Evaluate EXPRESSION, and repeat as long as it returns -1 with `errno'
  725. set to EINTR. */
  726. # define TEMP_FAILURE_RETRY(expression) \
  727. (__extension__ \
  728. ({ long int __result; \
  729. do __result = (long int) (expression); \
  730. while (__result == -1L && errno == EINTR); \
  731. __result; })) \
  732. /* This variable is set nonzero at startup if the process's effective
  733. IDs differ from its real IDs, or it is otherwise indicated that
  734. extra security should be used. When this is set the dynamic linker
  735. and some functions contained in the C library ignore various
  736. environment variables that normally affect them. */
  737. extern int __libc_enable_secure;
  738. #endif
  739. #if defined __USE_POSIX199309 || defined __USE_UNIX98
  740. /* Synchronize at least the data part of a file with the underlying
  741. media. */
  742. extern int fdatasync __P ((int __fildes));
  743. #endif /* Use POSIX199309 */
  744. /* XPG4.2 specifies that prototypes for the encryption functions must
  745. be defined here. */
  746. #ifdef __USE_XOPEN
  747. /* Encrypt at most 8 characters from KEY using salt to perturb DES. */
  748. extern char *crypt __P ((__const char *__key, __const char *__salt));
  749. /* Setup DES tables according KEY. */
  750. extern void setkey __P ((__const char *__key));
  751. /* Encrypt data in BLOCK in place if EDFLAG is zero; otherwise decrypt
  752. block in place. */
  753. extern void encrypt __P ((char *__block, int __edflag));
  754. /* Swab pairs bytes in the first N bytes of the area pointed to by
  755. FROM and copy the result to TO. The value of TO must not be in the
  756. range [FROM - N + 1, FROM - 1]. If N is odd the first byte in FROM
  757. is without partner. */
  758. extern void swab __P ((__const __ptr_t __from, __ptr_t __to, ssize_t __n));
  759. #endif
  760. /* The Single Unix specification, version 2, demands these prototypes
  761. to be here. They are also found in <stdio.h>. */
  762. #ifdef __USE_XOPEN
  763. /* Return the name of the controlling terminal. */
  764. extern char *ctermid __P ((char *__s));
  765. /* Return the name of the current user. This function should not be
  766. used and might go away some time. */
  767. extern char *cuserid __P ((char *__s));
  768. /* Rename file OLD to NEW. */
  769. extern int rename __P ((__const char *__old, __const char *__new));
  770. #endif
  771. #ifdef __USE_POSIX199309
  772. /* This function is only available if the system has POSIX threads. */
  773. /* Install handlers to be called when a new process is created with FORK.
  774. The PREPARE handler is called in the parent process just before performing
  775. FORK. The PARENT handler is called in the parent process just after FORK.
  776. The CHILD handler is called in the child process. Each of the three
  777. handlers can be NULL, meaning that no handler needs to be called at that
  778. point.
  779. PTHREAD_ATFORK can be called several times, in which case the PREPARE
  780. handlers are called in LIFO order (last added with PTHREAD_ATFORK,
  781. first called before FORK), and the PARENT and CHILD handlers are called
  782. in FIFO (first added, first called). */
  783. extern int pthread_atfork __P ((void (*__prepare) (void),
  784. void (*__parent) (void),
  785. void (*__child) (void)));
  786. #endif
  787. #ifdef __VFORK_MACRO__
  788. #include <bits/vfork.h>
  789. #endif
  790. __END_DECLS
  791. #endif /* unistd.h */