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