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