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