1 /* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
20 * POSIX Standard: 2.10 Symbolic Constants <unistd.h>
30 /* These may be used to determine what facilities are present at compile time.
31 Their values can be obtained at run time from `sysconf'. */
33 /* POSIX Standard approved as ISO/IEC 9945-1 as of August, 1988 and
34 extended by POSIX-1b (aka POSIX-4) and POSIX-1c (aka POSIX threads). */
35 #define _POSIX_VERSION 199506L
37 /* These are not #ifdef __USE_POSIX2 because they are
38 in the theoretically application-owned namespace. */
40 /* POSIX Standard approved as ISO/IEC 9945-2 as of December, 1993. */
41 #define _POSIX2_C_VERSION 199209L
43 /* If defined, the implementation supports the
44 C Language Bindings Option. */
45 #define _POSIX2_C_BIND 1
47 /* If defined, the implementation supports the
48 C Language Development Utilities Option. */
49 #define _POSIX2_C_DEV 1
51 /* If defined, the implementation supports the
52 Software Development Utilities Option. */
53 #define _POSIX2_SW_DEV 1
55 /* If defined, the implementation supports the
56 creation of locales with the localedef utility. */
57 #define _POSIX2_LOCALEDEF 1
59 /* Library conforms to X/Open version 4. */
60 #define _XOPEN_VERSION 4
62 /* Commands and utilities from XPG4 are available. */
63 #define _XOPEN_XCU_VERSION 4
65 /* We are compatible with the old published standards as well. */
70 /* The X/Open Unix extensions are available. */
73 /* Encryption is present. */
74 #define _XOPEN_CRYPT 1
76 /* The enhanced internationalization capabilities according to XPG4.2
78 #define _XOPEN_ENH_I18N 1
81 /* Get values of POSIX options:
83 If these symbols are defined, the corresponding features are
84 always available. If not, they may be available sometimes.
85 The current values can be obtained with `sysconf'.
87 _POSIX_JOB_CONTROL Job control is supported.
88 _POSIX_SAVED_IDS Processes have a saved set-user-ID
89 and a saved set-group-ID.
90 _POSIX_REALTIME_SIGNALS Real-time, queued signals are supported.
91 _POSIX_PRIORITY_SCHEDULING Priority scheduling is supported.
92 _POSIX_TIMERS POSIX.4 clocks and timers are supported.
93 _POSIX_ASYNCHRONOUS_IO Asynchronous I/O is supported.
94 _POSIX_PRIORITIZED_IO Prioritized asynchronous I/O is supported.
95 _POSIX_SYNCHRONIZED_IO Synchronizing file data is supported.
96 _POSIX_FSYNC The fsync function is present.
97 _POSIX_MAPPED_FILES Mapping of files to memory is supported.
98 _POSIX_MEMLOCK Locking of all memory is supported.
99 _POSIX_MEMLOCK_RANGE Locking of ranges of memory is supported.
100 _POSIX_MEMORY_PROTECTION Setting of memory protections is supported.
101 _POSIX_MESSAGE_PASSING POSIX.4 message queues are supported.
102 _POSIX_SEMAPHORES POSIX.4 counting semaphores are supported.
103 _POSIX_SHARED_MEMORY_OBJECTS POSIX.4 shared memory objects are supported.
104 _POSIX_PII Protocol-independent interfaces are supported.
105 _POSIX_PII_XTI XTI protocol-indep. interfaces are supported.
106 _POSIX_PII_SOCKET Socket protocol-indep. interfaces are supported.
107 _POSIX_PII_INTERNET Internet family of protocols supported.
108 _POSIX_PII_INTERNET_STREAM Connection-mode Internet protocol supported.
109 _POSIX_PII_INTERNET_DGRAM Connectionless Internet protocol supported.
110 _POSIX_PII_OSI ISO/OSI family of protocols supported.
111 _POSIX_PII_OSI_COTS Connection-mode ISO/OSI service supported.
112 _POSIX_PII_OSI_CLTS Connectionless ISO/OSI service supported.
113 _POSIX_POLL Implementation supports `poll' function.
114 _POSIX_SELECT Implementation supports `select' and `pselect'.
116 _XOPEN_SHM Shared memory interface according to XPG4.2.
118 If any of these symbols is defined as -1, the corresponding option is not
119 true for any file. If any is defined as other than -1, the corresponding
120 option is true for all files. If a symbol is not defined at all, the value
121 for a specific file can be obtained from `pathconf' and `fpathconf'.
123 _POSIX_CHOWN_RESTRICTED Only the super user can use `chown' to change
124 the owner of a file. `chown' can only be used
125 to change the group ID of a file to a group of
126 which the calling process is a member.
127 _POSIX_NO_TRUNC Pathname components longer than
128 NAME_MAX generate an error.
129 _POSIX_VDISABLE If defined, if the value of an element of the
130 `c_cc' member of `struct termios' is
131 _POSIX_VDISABLE, no character will have the
132 effect associated with that element.
133 _POSIX_SYNC_IO Synchronous I/O may be performed.
134 _POSIX_ASYNC_IO Asynchronous I/O may be performed.
135 _POSIX_PRIO_IO Prioritized Asynchronous I/O may be performed.
137 Support for the Large File Support interface is not generally available.
138 If it is available the following constants are defined to one.
139 _LFS64_LARGEFILE Low-level I/O supports large files.
140 _LFS64_STDIO Standard I/O supports large files.
143 #include <bits/posix_opt.h>
146 /* Standard file descriptors. */
147 #define STDIN_FILENO 0 /* Standard input. */
148 #define STDOUT_FILENO 1 /* Standard output. */
149 #define STDERR_FILENO 2 /* Standard error output. */
152 /* All functions that are not declared anywhere else. */
154 #include <bits/types.h>
157 typedef __ssize_t ssize_t
;
158 # define ssize_t ssize_t
161 #define __need_size_t
166 /* The Single Unix specification says that some more types are
169 typedef __gid_t gid_t
;
174 typedef __uid_t uid_t
;
179 # ifndef __USE_FILE_OFFSET64
180 typedef __off_t off_t
;
182 typedef __off64_t off_t
;
186 # if defined __USE_LARGEFILE64 && !defined off64_t
187 typedef __off64_t off64_t
;
188 # define off64_t off64_t
192 typedef __pid_t pid_t
;
197 /* Values for the second argument to access.
198 These may be OR'd together. */
199 #define R_OK 4 /* Test for read permission. */
200 #define W_OK 2 /* Test for write permission. */
201 #define X_OK 1 /* Test for execute permission. */
202 #define F_OK 0 /* Test for existence. */
204 /* Test for access to NAME using the real UID and real GID. */
205 extern int __access
__P ((__const
char *__name
, int __type
));
206 extern int access
__P ((__const
char *__name
, int __type
));
209 /* Test for access to NAME using the effective UID and GID
210 (as normal file operations use). */
211 extern int __euidaccess
__P ((__const
char *__name
, int __type
));
212 extern int euidaccess
__P ((__const
char *__name
, int __type
));
216 /* Values for the WHENCE argument to lseek. */
217 #ifndef _STDIO_H /* <stdio.h> has the same definitions. */
218 # define SEEK_SET 0 /* Seek from beginning of file. */
219 # define SEEK_CUR 1 /* Seek from current position. */
220 # define SEEK_END 2 /* Seek from end of file. */
223 #if defined __USE_BSD && !defined L_SET
224 /* Old BSD names for the same constants; just for compatibility. */
225 # define L_SET SEEK_SET
226 # define L_INCR SEEK_CUR
227 # define L_XTND SEEK_END
231 /* Move FD's file position to OFFSET bytes from the
232 beginning of the file (if WHENCE is SEEK_SET),
233 the current position (if WHENCE is SEEK_CUR),
234 or the end of the file (if WHENCE is SEEK_END).
235 Return the new file position. */
236 extern __off_t __lseek
__P ((int __fd
, __off_t __offset
, int __whence
));
237 #ifndef __USE_FILE_OFFSET64
238 extern __off_t lseek
__P ((int __fd
, __off_t __offset
, int __whence
));
240 extern __off_t lseek
__P ((int __fd
, __off_t __offset
, int __whence
))
243 #ifdef __USE_LARGEFILE64
244 extern __off64_t lseek64
__P ((int __fd
, __off64_t __offset
, int __whence
));
247 /* Close the file descriptor FD. */
248 extern int __close
__P ((int __fd
));
249 extern int close
__P ((int __fd
));
251 /* Read NBYTES into BUF from FD. Return the
252 number read, -1 for errors or 0 for EOF. */
253 extern ssize_t __read
__P ((int __fd
, __ptr_t __buf
, size_t __nbytes
));
254 extern ssize_t read
__P ((int __fd
, __ptr_t __buf
, size_t __nbytes
));
256 /* Write N bytes of BUF to FD. Return the number written, or -1. */
257 extern ssize_t __write
__P ((int __fd
, __const __ptr_t __buf
, size_t __n
));
258 extern ssize_t write
__P ((int __fd
, __const __ptr_t __buf
, size_t __n
));
261 /* Read NBYTES into BUF from FD at the given position OFFSET without
262 changing the file pointer. Return the number read, -1 for errors
264 # ifndef __USE_FILE_OFFSET64
265 extern ssize_t pread
__P ((int __fd
, __ptr_t __buf
, size_t __nbytes
,
268 extern ssize_t pread
__P ((int __fd
, __ptr_t __buf
, size_t __nbytes
,
269 __off_t __offset
)) __asm__ ("pread64");
271 # ifdef __USE_LARGEFILE64
272 extern ssize_t pread64
__P ((int __fd
, __ptr_t __buf
, size_t __nbytes
,
273 __off64_t __offset
));
276 /* Write N bytes of BUF to FD at the given position OFFSET without
277 changing the file pointer. Return the number written, or -1. */
278 # ifndef __USE_FILE_OFFSET64
279 extern ssize_t pwrite
__P ((int __fd
, __const __ptr_t __buf
, size_t __n
,
282 extern ssize_t pwrite
__P ((int __fd
, __const __ptr_t __buf
, size_t __n
,
283 __off_t __offset
)) __asm__ ("pwrite64");
285 # ifdef __USE_LARGEFILE64
286 extern ssize_t pwrite64
__P ((int __fd
, __const __ptr_t __buf
, size_t __n
,
287 __off64_t __offset
));
292 /* Create a one-way communication channel (pipe).
293 If successful, two file descriptors are stored in PIPEDES;
294 bytes written on PIPEDES[1] can be read from PIPEDES[0].
295 Returns 0 if successful, -1 if not. */
296 extern int __pipe
__P ((int __pipedes
[2]));
297 extern int pipe
__P ((int __pipedes
[2]));
299 /* Schedule an alarm. In SECONDS seconds, the process will get a SIGALRM.
300 If SECONDS is zero, any currently scheduled alarm will be cancelled.
301 The function returns the number of seconds remaining until the last
302 alarm scheduled would have signaled, or zero if there wasn't one.
303 There is no return value to indicate an error, but you can set `errno'
304 to 0 and check its value after calling `alarm', and this might tell you.
305 The signal may come late due to processor scheduling. */
306 extern unsigned int alarm
__P ((unsigned int __seconds
));
308 /* Make the process sleep for SECONDS seconds, or until a signal arrives
309 and is not ignored. The function returns the number of seconds less
310 than SECONDS which it actually slept (thus zero if it slept the full time).
311 If a signal handler does a `longjmp' or modifies the handling of the
312 SIGALRM signal while inside `sleep' call, the handling of the SIGALRM
313 signal afterwards is undefined. There is no return value to indicate
314 error, but if `sleep' returns SECONDS, it probably didn't work. */
315 extern unsigned int __sleep
__P ((unsigned int __seconds
));
316 extern unsigned int sleep
__P ((unsigned int __seconds
));
318 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
319 /* Set an alarm to go off (generating a SIGALRM signal) in VALUE
320 microseconds. If INTERVAL is nonzero, when the alarm goes off, the
321 timer is reset to go off every INTERVAL microseconds thereafter.
322 Returns the number of microseconds remaining before the alarm. */
323 extern unsigned int ualarm
__P ((unsigned int __value
,
324 unsigned int __interval
));
326 /* Sleep USECONDS microseconds, or until a signal arrives that is not blocked
328 extern void usleep
__P ((unsigned int __useconds
));
332 /* Suspend the process until a signal arrives.
333 This always returns -1 and sets `errno' to EINTR. */
334 extern int pause
__P ((void));
337 /* Change the owner and group of FILE. */
338 extern int __chown
__P ((__const
char *__file
,
339 __uid_t __owner
, __gid_t __group
));
340 extern int chown
__P ((__const
char *__file
,
341 __uid_t __owner
, __gid_t __group
));
343 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
344 /* Change the owner and group of the file that FD is open on. */
345 extern int __fchown
__P ((int __fd
,
346 __uid_t __owner
, __gid_t __group
));
347 extern int fchown
__P ((int __fd
,
348 __uid_t __owner
, __gid_t __group
));
351 /* Change owner and group of FILE, if it is a symbolic
352 link the ownership of the symbolic link is changed. */
353 extern int __lchown
__P ((__const
char *__file
, __uid_t __owner
,
355 extern int lchown
__P ((__const
char *__file
, __uid_t __owner
,
358 #endif /* Use BSD || X/Open Unix. */
360 /* Change the process's working directory to PATH. */
361 extern int __chdir
__P ((__const
char *__path
));
362 extern int chdir
__P ((__const
char *__path
));
364 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
365 /* Change the process's working directory to the one FD is open on. */
366 extern int __fchdir
__P ((int __fd
));
367 extern int fchdir
__P ((int __fd
));
370 /* Get the pathname of the current working directory,
371 and put it in SIZE bytes of BUF. Returns NULL if the
372 directory couldn't be determined or SIZE was too small.
373 If successful, returns BUF. In GNU, if BUF is NULL,
374 an array is allocated with `malloc'; the array is SIZE
375 bytes long, unless SIZE == 0, in which case it is as
377 extern char *__getcwd
__P ((char *__buf
, size_t __size
));
378 extern char *getcwd
__P ((char *__buf
, size_t __size
));
381 /* Return a malloc'd string containing the current directory name.
382 If the environment variable `PWD' is set, and its value is correct,
383 that value is used. */
384 extern char *get_current_dir_name
__P ((void));
386 /* Get the canonical absolute name of the named directory, and put it in SIZE
387 bytes of BUF. Returns NULL if the directory couldn't be determined or
388 SIZE was too small. If successful, returns BUF. In GNU, if BUF is
389 NULL, an array is allocated with `malloc'; the array is SIZE bytes long,
390 unless SIZE <= 0, in which case it is as big as necessary. */
392 char *__canonicalize_directory_name_internal
__P ((__const
char *__thisdir
,
397 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
398 /* Put the absolute pathname of the current working directory in BUF.
399 If successful, return BUF. If not, put an error message in
400 BUF and return NULL. BUF should be at least PATH_MAX bytes long. */
401 extern char *getwd
__P ((char *__buf
));
405 /* Duplicate FD, returning a new file descriptor on the same file. */
406 extern int __dup
__P ((int __fd
));
407 extern int dup
__P ((int __fd
));
409 /* Duplicate FD to FD2, closing FD2 and making it open on the same file. */
410 extern int __dup2
__P ((int __fd
, int __fd2
));
411 extern int dup2
__P ((int __fd
, int __fd2
));
413 /* NULL-terminated array of "NAME=VALUE" environment variables. */
414 extern char **__environ
;
416 extern char **environ
;
420 /* Replace the current process, executing PATH with arguments ARGV and
421 environment ENVP. ARGV and ENVP are terminated by NULL pointers. */
422 extern int __execve
__P ((__const
char *__path
, char *__const __argv
[],
423 char *__const __envp
[]));
424 extern int execve
__P ((__const
char *__path
, char *__const __argv
[],
425 char *__const __envp
[]));
428 /* Execute the file FD refers to, overlaying the running program image.
429 ARGV and ENVP are passed to the new program, as for `execve'. */
430 extern int fexecve
__P ((int __fd
,
431 char *__const __argv
[], char *__const __envp
[]));
436 /* Execute PATH with arguments ARGV and environment from `environ'. */
437 extern int execv
__P ((__const
char *__path
, char *__const __argv
[]));
439 /* Execute PATH with all arguments after PATH until a NULL pointer,
440 and the argument after that for environment. */
441 extern int execle
__P ((__const
char *__path
, __const
char *__arg
, ...));
443 /* Execute PATH with all arguments after PATH until
444 a NULL pointer and environment from `environ'. */
445 extern int execl
__P ((__const
char *__path
, __const
char *__arg
, ...));
447 /* Execute FILE, searching in the `PATH' environment variable if it contains
448 no slashes, with arguments ARGV and environment from `environ'. */
449 extern int execvp
__P ((__const
char *__file
, char *__const __argv
[]));
451 /* Execute FILE, searching in the `PATH' environment variable if
452 it contains no slashes, with all arguments after FILE until a
453 NULL pointer and environment from `environ'. */
454 extern int execlp
__P ((__const
char *__file
, __const
char *__arg
, ...));
457 #if defined __USE_MISC || defined __USE_XOPEN
458 /* Add INC to priority of the current process. */
459 extern int nice
__P ((int __inc
));
463 /* Terminate program execution with the low-order 8 bits of STATUS. */
464 extern void _exit
__P ((int __status
)) __attribute__ ((__noreturn__
));
467 /* Get the `_PC_*' symbols for the NAME argument to `pathconf' and `fpathconf';
468 the `_SC_*' symbols for the NAME argument to `sysconf';
469 and the `_CS_*' symbols for the NAME argument to `confstr'. */
470 #include <bits/confname.h>
472 /* Get file-specific configuration information about PATH. */
473 extern long int __pathconf
__P ((__const
char *__path
, int __name
));
474 extern long int pathconf
__P ((__const
char *__path
, int __name
));
476 /* Get file-specific configuration about descriptor FD. */
477 extern long int __fpathconf
__P ((int __fd
, int __name
));
478 extern long int fpathconf
__P ((int __fd
, int __name
));
480 /* Get the value of the system variable NAME. */
481 extern long int __sysconf
__P ((int __name
));
482 extern long int sysconf
__P ((int __name
));
485 /* Get the value of the string-valued system variable NAME. */
486 extern size_t confstr
__P ((int __name
, char *__buf
, size_t __len
));
490 /* Get the process ID of the calling process. */
491 extern __pid_t __getpid
__P ((void));
492 extern __pid_t getpid
__P ((void));
494 /* Get the process ID of the calling process's parent. */
495 extern __pid_t __getppid
__P ((void));
496 extern __pid_t getppid
__P ((void));
498 /* Get the process group ID of the calling process. */
499 extern __pid_t getpgrp
__P ((void));
500 /* The old BSD definition is a bit different. */
501 extern __pid_t __bsd_getpgrp
__P ((__pid_t __pid
));
503 /* When we explicitely compile BSD sources use the BSD definition of this
504 function. Please note that we cannot use parameters for the macro. */
505 # define getpgrp __bsd_getpgrp
508 /* Set the process group ID of the process matching PID to PGID.
509 If PID is zero, the current process's process group ID is set.
510 If PGID is zero, the process ID of the process is used. */
511 extern int __setpgid
__P ((__pid_t __pid
, __pid_t __pgid
));
512 extern int setpgid
__P ((__pid_t __pid
, __pid_t __pgid
));
514 /* Get the process group ID of process PID. */
515 extern __pid_t __getpgid
__P ((__pid_t __pid
));
516 #ifdef __USE_XOPEN_EXTENDED
517 extern __pid_t getpgid
__P ((__pid_t __pid
));
520 #if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
521 /* Both System V and BSD have `setpgrp' functions, but with different
522 calling conventions. The BSD function is the same as POSIX.1 `setpgid'
523 (above). The System V function takes no arguments and puts the calling
524 process in its on group like `setpgid (0, 0)'.
526 New programs should always use `setpgid' instead.
528 The default in GNU is to provide the System V function. The BSD
529 function is available under -D_BSD_SOURCE with -lbsd-compat. */
533 /* Set the process group ID of the calling process to its own PID.
534 This is exactly the same as `setpgid (0, 0)'. */
535 extern int setpgrp
__P ((void));
539 /* Another name for `setpgid' (above). */
540 extern int setpgrp
__P ((__pid_t __pid
, __pid_t __pgrp
));
542 # endif /* Favor BSD. */
543 #endif /* Use SVID or BSD. */
545 /* Create a new session with the calling process as its leader.
546 The process group IDs of the session and the calling process
547 are set to the process ID of the calling process, which is returned. */
548 extern __pid_t __setsid
__P ((void));
549 extern __pid_t setsid
__P ((void));
551 #ifdef __USE_XOPEN_EXTENDED
552 /* Return the session ID of the given process. */
553 extern __pid_t getsid
__P ((__pid_t __pid
));
556 /* Get the real user ID of the calling process. */
557 extern __uid_t __getuid
__P ((void));
558 extern __uid_t getuid
__P ((void));
560 /* Get the effective user ID of the calling process. */
561 extern __uid_t __geteuid
__P ((void));
562 extern __uid_t geteuid
__P ((void));
564 /* Get the real group ID of the calling process. */
565 extern __gid_t __getgid
__P ((void));
566 extern __gid_t getgid
__P ((void));
568 /* Get the effective group ID of the calling process. */
569 extern __gid_t __getegid
__P ((void));
570 extern __gid_t getegid
__P ((void));
572 /* If SIZE is zero, return the number of supplementary groups
573 the calling process is in. Otherwise, fill in the group IDs
574 of its supplementary groups in LIST and return the number written. */
575 extern int __getgroups
__P ((int __size
, __gid_t __list
[]));
576 extern int getgroups
__P ((int __size
, __gid_t __list
[]));
579 /* Return nonzero iff the calling process is in group GID. */
580 extern int __group_member
__P ((__gid_t __gid
));
581 extern int group_member
__P ((__gid_t __gid
));
584 /* Set the user ID of the calling process to UID.
585 If the calling process is the super-user, set the real
586 and effective user IDs, and the saved set-user-ID to UID;
587 if not, the effective user ID is set to UID. */
588 extern int __setuid
__P ((__uid_t __uid
));
589 extern int setuid
__P ((__uid_t __uid
));
591 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
592 /* Set the real user ID of the calling process to RUID,
593 and the effective user ID of the calling process to EUID. */
594 extern int __setreuid
__P ((__uid_t __ruid
, __uid_t __euid
));
595 extern int setreuid
__P ((__uid_t __ruid
, __uid_t __euid
));
599 /* Set the effective user ID of the calling process to UID. */
600 extern int seteuid
__P ((__uid_t __uid
));
601 #endif /* Use BSD. */
603 /* Set the group ID of the calling process to GID.
604 If the calling process is the super-user, set the real
605 and effective group IDs, and the saved set-group-ID to GID;
606 if not, the effective group ID is set to GID. */
607 extern int __setgid
__P ((__gid_t __gid
));
608 extern int setgid
__P ((__gid_t __gid
));
610 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
611 /* Set the real group ID of the calling process to RGID,
612 and the effective group ID of the calling process to EGID. */
613 extern int __setregid
__P ((__gid_t __rgid
, __gid_t __egid
));
614 extern int setregid
__P ((__gid_t __rgid
, __gid_t __egid
));
618 /* Set the effective group ID of the calling process to GID. */
619 extern int setegid
__P ((__gid_t __gid
));
620 #endif /* Use BSD. */
623 /* Clone the calling process, creating an exact copy.
624 Return -1 for errors, 0 to the new process,
625 and the process ID of the new process to the old process. */
626 extern __pid_t __fork
__P ((void));
627 extern __pid_t fork
__P ((void));
629 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
630 /* Clone the calling process, but without copying the whole address space.
631 The the calling process is suspended until the the new process exits or is
632 replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
633 and the process ID of the new process to the old process. */
634 extern __pid_t __vfork
__P ((void));
635 extern __pid_t vfork
__P ((void));
636 #endif /* Use BSD. */
639 /* Return the pathname of the terminal FD is open on, or NULL on errors.
640 The returned storage is good only until the next call to this function. */
641 extern char *ttyname
__P ((int __fd
));
643 /* Store at most BUFLEN characters of the pathname of the terminal FD is
644 open on in BUF. Return 0 on success, otherwise an error number. */
645 extern int __ttyname_r
__P ((int __fd
, char *__buf
, size_t __buflen
));
646 extern int ttyname_r
__P ((int __fd
, char *__buf
, size_t __buflen
));
648 /* Return 1 if FD is a valid descriptor associated
649 with a terminal, zero if not. */
650 extern int __isatty
__P ((int __fd
));
651 extern int isatty
__P ((int __fd
));
653 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
654 /* Return the index into the active-logins file (utmp) for
655 the controlling terminal. */
656 extern int ttyslot
__P ((void));
660 /* Make a link to FROM named TO. */
661 extern int __link
__P ((__const
char *__from
, __const
char *__to
));
662 extern int link
__P ((__const
char *__from
, __const
char *__to
));
664 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
665 /* Make a symbolic link to FROM named TO. */
666 extern int __symlink
__P ((__const
char *__from
, __const
char *__to
));
667 extern int symlink
__P ((__const
char *__from
, __const
char *__to
));
669 /* Read the contents of the symbolic link PATH into no more than
670 LEN bytes of BUF. The contents are not null-terminated.
671 Returns the number of characters read, or -1 for errors. */
672 extern int __readlink
__P ((__const
char *__path
, char *__buf
, size_t __len
));
673 extern int readlink
__P ((__const
char *__path
, char *__buf
, size_t __len
));
674 #endif /* Use BSD. */
676 /* Remove the link NAME. */
677 extern int __unlink
__P ((__const
char *__name
));
678 extern int unlink
__P ((__const
char *__name
));
680 /* Remove the directory PATH. */
681 extern int __rmdir
__P ((__const
char *__path
));
682 extern int rmdir
__P ((__const
char *__path
));
685 /* Return the foreground process group ID of FD. */
686 extern __pid_t tcgetpgrp
__P ((int __fd
));
688 /* Set the foreground process group ID of FD set PGRP_ID. */
689 extern int tcsetpgrp
__P ((int __fd
, __pid_t __pgrp_id
));
692 /* Return the login name of the user. */
693 extern char *getlogin
__P ((void));
694 #ifdef __USE_REENTRANT
695 /* Return at most NAME_LEN characters of the login name of the user in NAME.
696 If it cannot be determined or some other error occurred, return the error
697 code. Otherwise return 0. */
698 extern int getlogin_r
__P ((char *__name
, size_t __name_len
));
702 /* Set the login name returned by `getlogin'. */
703 extern int setlogin
__P ((__const
char *__name
));
708 /* Process the arguments in ARGV (ARGC of them, minus
709 the program name) for options given in OPTS.
711 If `opterr' is zero, no messages are generated
712 for invalid options; it defaults to 1.
713 `optind' is the current index into ARGV.
714 `optarg' is the argument corresponding to the current option.
715 Return the option character from OPTS just read.
716 Return -1 when there are no more options.
717 For unrecognized options, or options missing arguments,
718 `optopt' is set to the option letter, and '?' is returned.
720 The OPTS string is a list of characters which are recognized option
721 letters, optionally followed by colons, specifying that that letter
722 takes an argument, to be placed in `optarg'.
724 If a letter in OPTS is followed by two colons, its argument is optional.
725 This behavior is specific to the GNU `getopt'.
727 The argument `--' causes premature termination of argument scanning,
728 explicitly telling `getopt' that there are no more options.
730 If OPTS begins with `--', then non-option arguments
731 are treated as arguments to the option '\0'.
732 This behavior is specific to the GNU `getopt'. */
733 extern int getopt
__P ((int __argc
, char *__const
* __argv
,
734 __const
char *__opts
));
742 #if defined __USE_BSD || defined __USE_XOPEN
744 /* Put the name of the current host in no more than LEN bytes of NAME.
745 The result is null-terminated if LEN is large enough for the full
746 name and the terminator. */
747 extern int __gethostname
__P ((char *__name
, size_t __len
));
748 extern int gethostname
__P ((char *__name
, size_t __len
));
750 /* Set the name of the current host to NAME, which is LEN bytes long.
751 This call is restricted to the super-user. */
752 extern int sethostname
__P ((__const
char *__name
, size_t __len
));
754 /* Set the current machine's Internet number to ID.
755 This call is restricted to the super-user. */
756 extern int sethostid
__P ((long int __id
));
759 /* Get and set the NIS (aka YP) domain name, if any.
760 Called just like `gethostname' and `sethostname'.
761 The NIS domain name is usually the empty string when not using NIS. */
762 extern int getdomainname
__P ((char *__name
, size_t __len
));
763 extern int setdomainname
__P ((__const
char *__name
, size_t __len
));
766 /* Make all changes done to FD actually appear on disk. */
767 extern int fsync
__P ((int __fd
));
770 /* Revoke access permissions to all processes currently communicating
771 with the control terminal, and then send a SIGHUP signal to the process
772 group of the control terminal. */
773 extern int vhangup
__P ((void));
775 /* Revoke the access of all descriptors currently open on FILE. */
776 extern int revoke
__P ((__const
char *__file
));
779 /* Enable statistical profiling, writing samples of the PC into at most
780 SIZE bytes of SAMPLE_BUFFER; every processor clock tick while profiling
781 is enabled, the system examines the user PC and increments
782 SAMPLE_BUFFER[((PC - OFFSET) / 2) * SCALE / 65536]. If SCALE is zero,
783 disable profiling. Returns zero on success, -1 on error. */
784 extern int __profil
__P ((unsigned short int *__sample_buffer
, size_t __size
,
785 size_t __offset
, unsigned int __scale
));
786 extern int profil
__P ((unsigned short int *__sample_buffer
, size_t __size
,
787 size_t __offset
, unsigned int __scale
));
790 /* Turn accounting on if NAME is an existing file. The system will then write
791 a record for each process as it terminates, to this file. If NAME is NULL,
792 turn accounting off. This call is restricted to the super-user. */
793 extern int acct
__P ((__const
char *__name
));
795 /* Make PATH be the root directory (the starting point for absolute paths).
796 This call is restricted to the super-user. */
797 extern int chroot
__P ((__const
char *__path
));
800 /* Successive calls return the shells listed in `/etc/shells'. */
801 extern char *getusershell
__P ((void));
802 extern void endusershell
__P ((void)); /* Discard cached info. */
803 extern void setusershell
__P ((void)); /* Rewind and re-read the file. */
806 /* Prompt with PROMPT and read a string from the terminal without echoing.
807 Uses /dev/tty if possible; otherwise stderr and stdin. */
808 extern char *getpass
__P ((__const
char *__prompt
));
810 /* Put the program in the background, and dissociate from the controlling
811 terminal. If NOCHDIR is zero, do `chdir ("/")'. If NOCLOSE is zero,
812 redirects stdin, stdout, and stderr to /dev/null. */
813 extern int daemon
__P ((int __nochdir
, int __noclose
));
815 #endif /* Use BSD || X/Open. */
818 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
820 /* Return the current machine's Internet number. */
821 extern long int gethostid
__P ((void));
823 /* Make all changes done to all files actually appear on disk. */
824 extern int sync
__P ((void));
827 /* Return the number of bytes in a page. This is the system's page size,
828 which is not necessarily the same as the hardware page size. */
829 extern int __getpagesize
__P ((void));
830 extern int getpagesize
__P ((void));
833 /* Truncate FILE to LENGTH bytes. */
834 #ifndef __USE_FILE_OFFSET64
835 extern int truncate
__P ((__const
char *__file
, __off_t __length
));
837 extern int truncate
__P ((__const
char *__file
, __off_t __length
))
838 __asm__ ("truncate64");
840 #ifdef __USE_LARGEFILE64
841 extern int truncate64
__P ((__const
char *__file
, __off64_t __length
));
844 /* Truncate the file FD is open on to LENGTH bytes. */
845 #ifndef __USE_FILE_OFFSET64
846 extern int ftruncate
__P ((int __fd
, __off_t __length
));
848 extern int ftruncate
__P ((int __fd
, __off_t __length
))
849 __asm__ ("ftruncate64");
851 #ifdef __USE_LARGEFILE64
852 extern int ftruncate64
__P ((int __fd
, __off64_t __length
));
856 /* Return the maximum number of file descriptors
857 the current process could possibly have. */
858 extern int __getdtablesize
__P ((void));
859 extern int getdtablesize
__P ((void));
861 #endif /* Use BSD || X/Open Unix. */
864 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
866 /* Set the end of accessible data space (aka "the break") to ADDR.
867 Returns zero on success and -1 for errors (with errno set). */
868 extern int __brk
__P ((__ptr_t __addr
));
869 extern int brk
__P ((__ptr_t __addr
));
871 # define __need_ptrdiff_t
874 /* Increase or decrease the end of accessible data space by DELTA bytes.
875 If successful, returns the address the previous end of data space
876 (i.e. the beginning of the new space, if DELTA > 0);
877 returns (void *) -1 for errors (with errno set). */
878 extern __ptr_t __sbrk
__P ((ptrdiff_t __delta
));
879 extern __ptr_t sbrk
__P ((ptrdiff_t __delta
));
884 /* Invoke `system call' number SYSNO, passing it the remaining arguments.
885 This is completely system-dependent, and not often useful.
887 In Unix, `syscall' sets `errno' for all errors and most calls return -1
888 for errors; in many systems you cannot pass arguments or get return
889 values for all system calls (`pipe', `fork', and `getppid' typically
892 In Mach, all system calls take normal arguments and always return an
893 error code (zero for success). */
894 extern long int syscall
__P ((long int __sysno
, ...));
896 #endif /* Use misc. */
899 #if (defined __USE_MISC || defined __USE_XOPEN_EXTENDED) && !defined F_LOCK
900 /* NOTE: These declarations also appear in <fcntl.h>; be sure to keep both
901 files consistent. Some systems have them there and some here, and some
902 software depends on the macros being defined without including both. */
904 /* `lockf' is a simpler interface to the locking facilities of `fcntl'.
905 LEN is always relative to the current file position.
906 The CMD argument is one of the following. */
908 # define F_ULOCK 0 /* Unlock a previously locked region. */
909 # define F_LOCK 1 /* Lock a region for exclusive use. */
910 # define F_TLOCK 2 /* Test and lock a region for exclusive use. */
911 # define F_TEST 3 /* Test a region for other processes locks. */
913 # ifndef __USE_FILE_OFFSET64
914 extern int lockf
__P ((int __fd
, int __cmd
, __off_t __len
));
916 extern int lockf
__P ((int __fd
, int __cmd
, __off_t __len
))
919 # ifdef __USE_LARGEFILE64
920 extern int lockf64
__P ((int __fd
, int __cmd
, __off64_t __len
));
922 #endif /* Use misc and F_LOCK not already defined. */
927 /* Evaluate EXPRESSION, and repeat as long as it returns -1 with `errno'
930 # define TEMP_FAILURE_RETRY(expression) \
932 ({ long int __result; \
933 do __result = (long int) (expression); \
934 while (__result == -1L && errno == EINTR); \
938 /* This variable is set nonzero at startup if the process's effective
939 IDs differ from its real IDs, or it is otherwise indicated that
940 extra security should be used. When this is set the dynamic linker
941 and some functions contained in the C library ignore various
942 environment variables that normally affect them. */
943 extern int __libc_enable_secure
;
947 #if defined __USE_POSIX199309 || defined __USE_UNIX98
948 /* Synchronize at least the data part of a file with the underlying
950 extern int fdatasync
__P ((int __fildes
));
951 #endif /* Use POSIX199309 */
954 /* XPG4.2 specifies that prototypes for the encryption functions must
957 /* Encrypt at most 8 characters from KEY using salt to perturb DES. */
958 extern char *crypt
__P ((__const
char *__key
, __const
char *__salt
));
960 /* Setup DES tables according KEY. */
961 extern void setkey
__P ((__const
char *__key
));
963 /* Encrypt data in BLOCK in place if EDFLAG is zero; otherwise decrypt
965 extern void encrypt
__P ((char *__block
, int __edflag
));
968 /* Swab pairs bytes in the first N bytes of the area pointed to by
969 FROM and copy the result to TO. The value of TO must not be in the
970 range [FROM - N + 1, FROM - 1]. If N is odd the first byte in FROM
971 is without partner. */
972 extern void swab
__P ((__const __ptr_t __from
, __ptr_t __to
, ssize_t __n
));
976 /* The Single Unix specification, version 2, demands these prototypes
977 to be here. They are also found in <stdio.h>. */
979 /* Return the name of the controlling terminal. */
980 extern char *ctermid
__P ((char *__s
));
982 /* Return the name of the current user. */
983 extern char *cuserid
__P ((char *__s
));
988 #endif /* unistd.h */