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