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