unistd.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /* unistd.h <ndf@linux.mit.edu> */
  2. #include <features.h>
  3. #include <sys/types.h>
  4. #ifndef __UNISTD_H
  5. #define __UNISTD_H
  6. #include <errno.h>
  7. #ifdef __mc68000__
  8. #include <asm/unistd.h>
  9. #endif
  10. #define STDIN_FILENO 0
  11. #define STDOUT_FILENO 1
  12. #define STDERR_FILENO 2
  13. /* NULL-terminated array of "NAME=VALUE" environment variables. */
  14. extern char **__environ;
  15. extern char **environ;
  16. extern int close __P ((int));
  17. extern size_t read __P ((int __fd, char * __buf, size_t __nbytes));
  18. extern size_t write __P ((int __fd, __const char * __buf, size_t __n));
  19. extern off_t lseek __P ((int __fd, off_t __n, int __whence));
  20. extern int pipe __P ((int __pipedes[2]));
  21. extern unsigned int alarm __P ((unsigned int __seconds));
  22. extern int sleep __P ((unsigned int __seconds));
  23. extern void usleep __P ((unsigned long __microseconds));
  24. extern int pause __P ((void));
  25. extern char* crypt __P((__const char *__key, __const char *__salt));
  26. extern int isatty __P ((int __fd));
  27. extern char *ttyname __P ((int __fd));
  28. extern int readlink __P ((__const char *__path, char *__buf, size_t __len));
  29. extern int link __P ((__const char *__from, __const char *__to));
  30. extern int symlink __P ((__const char *__from, __const char *__to));
  31. extern int readlink __P ((__const char *__path, char *__buf, size_t __len));
  32. extern int unlink __P ((__const char *__name));
  33. extern char *getcwd __P ((char *__buf, size_t __size));
  34. /* Duplicate FD, returning a new file descriptor on the same file. */
  35. extern int dup __P ((int __fd));
  36. /* Duplicate FD to FD2, closing FD2 and making it open on the same file. */
  37. extern int dup2 __P ((int __fd, int __fd2));
  38. extern int fchdir __P ((int __fd));
  39. extern int chdir __P ((__const char *__path));
  40. extern int chown __P ((__const char *__file,
  41. uid_t __owner, gid_t __group));
  42. extern int fchown __P ((int __fd,
  43. uid_t __owner, gid_t __group));
  44. extern int fsync __P ((int __fd));
  45. extern int sync __P ((void));
  46. extern int rmdir __P ((__const char *__path));
  47. extern int rename __P((__const char* _old, __const char* _new));
  48. extern int access __P ((__const char *__name, int __type));
  49. extern int reboot __P ((int __magic, int __magic_too, int __flag));
  50. extern int mkstemp __P ((char * __template));
  51. extern char * mktemp __P ((char * __template));
  52. extern int _clone __P ((int (*fn)(void *arg), void *child_stack, int flags, void *arg));
  53. /* Return the current machine's Internet number. */
  54. extern long int gethostid __P ((void));
  55. /* Put the name of the current host in no more than LEN bytes of NAME.
  56. The result is null-terminated if LEN is large enough for the full
  57. name and the terminator. */
  58. extern int gethostname __P ((char *__name, size_t __len));
  59. /* Set the name of the current host to NAME, which is LEN bytes long.
  60. This call is restricted to the super-user. */
  61. extern int sethostname __P ((__const char *__name, size_t __len));
  62. /* Set the user ID of the calling process to UID.
  63. If the calling process is the super-user, set the real
  64. and effective user IDs, and the saved set-user-ID to UID;
  65. if not, the effective user ID is set to UID. */
  66. extern int setuid __P ((__uid_t __uid));
  67. /* Create a new session with the calling process as its leader.
  68. The process group IDs of the session and the calling process
  69. are set to the process ID of the calling process, which is returned. */
  70. extern __pid_t setsid __P ((void));
  71. /* Get the real user ID of the calling process. */
  72. extern __uid_t getuid __P ((void));
  73. /* Get the effective user ID of the calling process. */
  74. extern __uid_t geteuid __P ((void));
  75. /* Get the real group ID of the calling process. */
  76. extern __gid_t getgid __P ((void));
  77. /* Get the effective group ID of the calling process. */
  78. extern __gid_t getegid __P ((void));
  79. /* If SIZE is zero, return the number of supplementary groups
  80. the calling process is in. Otherwise, fill in the group IDs
  81. of its supplementary groups in LIST and return the number written. */
  82. extern int getgroups __P ((int __size, __gid_t __list[]));
  83. /* Return the foreground process group ID of FD. */
  84. extern __pid_t tcgetpgrp __P ((int __fd));
  85. /* Set the foreground process group ID of FD set PGRP_ID. */
  86. extern int tcsetpgrp __P ((int __fd, __pid_t __pgrp_id));
  87. /* Get the process group ID of the calling process.
  88. This function is different on old BSD. */
  89. extern __pid_t getpgrp __P ((void));
  90. /* Set the process group ID of the process matching PID to PGID.
  91. If PID is zero, the current process's process group ID is set.
  92. If PGID is zero, the process ID of the process is used. */
  93. extern int setpgid __P ((__pid_t __pid, __pid_t __pgid));
  94. /* Get the process ID of the calling process. */
  95. extern __pid_t getpid __P ((void));
  96. /* Make PATH be the root directory (the starting point for absolute paths).
  97. This call is restricted to the super-user. */
  98. extern int chroot __P ((__const char *__path));
  99. /* Execute PATH with all arguments after PATH until
  100. a NULL pointer and environment from `environ'. */
  101. extern int execl __P ((__const char *__path, __const char *__arg, ...));
  102. /* Execute FILE, searching in the `PATH' environment variable if
  103. it contains no slashes, with all arguments after FILE until a
  104. NULL pointer and environment from `environ'. */
  105. extern int execlp __P ((__const char *__file, __const char *__arg, ...));
  106. /* Execute PATH with arguments ARGV and environment from `environ'. */
  107. extern int execv __P ((__const char *__path, char *__const __argv[]));
  108. /* Replace the current process, executing PATH with arguments ARGV and
  109. environment ENVP. ARGV and ENVP are terminated by NULL pointers. */
  110. extern int execve __P ((__const char *__path, char *__const __argv[],
  111. char *__const __envp[]));
  112. /* Execute FILE, searching in the `PATH' environment variable if it contains
  113. no slashes, with arguments ARGV and environment from `environ'. */
  114. extern int execvp __P ((__const char *__file, char *__const __argv[]));
  115. /* Execute PATH with arguments ARGV and environment ENVP. */
  116. extern int execvep __P ((__const char *path, char *__const __argv[],
  117. char *__const __envp[]));
  118. /* Terminate program execution with the low-order 8 bits of STATUS. */
  119. extern void _exit __P ((int __status)) __attribute__ ((__noreturn__));
  120. /* Clone the calling process, creating an exact copy.
  121. * Return -1 for errors, 0 to the new process,
  122. * and the process ID of the new process to the old process. */
  123. extern __pid_t __fork __P ((void));
  124. extern __pid_t fork __P ((void));
  125. /* Clone the calling process, but without copying the whole address space.
  126. * The calling process is suspended until the new process exits or is
  127. * replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
  128. * and the process ID of the new process to the old process. */
  129. extern __pid_t vfork __P ((void));
  130. /* Return the number of bytes in a page. This is the system's page size,
  131. which is not necessarily the same as the hardware page size. */
  132. extern int getpagesize __P ((void)) __attribute__ ((__const__));
  133. #ifdef __USE_POSIX2
  134. /* Get definitions and prototypes for functions to process the
  135. arguments in ARGV (ARGC of them, minus the program name) for
  136. options given in OPTS. */
  137. # define __need_getopt
  138. # include <getopt.h>
  139. #endif
  140. #ifndef SEEK_SET
  141. #define SEEK_SET 0
  142. #define SEEK_CUR 1
  143. #define SEEK_END 2
  144. #endif
  145. #ifndef R_OK
  146. #define R_OK 4 /* Test for read permission. */
  147. #define W_OK 2 /* Test for write permission. */
  148. #define X_OK 1 /* Test for execute permission. */
  149. #define F_OK 0 /* Test for existence. */
  150. #endif
  151. #endif /* __UNISTD_H */