Posix_unistdSourcePOSIX unistd.h bindings.
This module provides OCaml bindings to POSIX functions defined in unistd.h.
It includes functions for file I/O, process control, user/group IDs, directory operations, and system configuration.
(* Read from a file descriptor *)
let buf = Bytes.create 1024 in
let n = Posix_unistd.read fd buf 0 1024 in
Printf.printf "Read %d bytes\n" n;
(* Get system configuration *)
let max_open = Posix_unistd.sysconf sc_open_max in
Printf.printf "Max open files: %d\n" max_openCommonly available sysconf names
POSIX options
POSIX.2 constants
X/Open constants
Read permission
Write permission
Execute permission
File exists
Read from a file descriptor.
See read(2).
Write to a file descriptor.
See write(2).
Read from a file descriptor at a given offset without changing the file offset.
See pread(2).
Write to a file descriptor at a given offset without changing the file offset.
See pwrite(2).
Close a file descriptor. See close(2).
Duplicate a file descriptor. See dup(2).
Duplicate a file descriptor to a specified descriptor. See dup2(2).
Create a pipe. See pipe(2).
Synchronize file data and metadata to disk. See fsync(2).
Synchronize file data (but not necessarily metadata) to disk. See fdatasync(2).
Schedule writes of all modified buffer cache blocks to disk. See sync(2).
Create a symbolic link. See symlink(2).
Read the target of a symbolic link. See readlink(2).
Change the current working directory to a directory referenced by a file descriptor. See fchdir(2).
Reposition the file offset. See lseek(2).
Access permission flags for access.
Check file accessibility. See access(2).
Change file ownership using a file descriptor. See fchown(2).
Change ownership of a symbolic link itself. See lchown(2).
Truncate a file to a specified length. See truncate(2).
Truncate a file to a specified length using a file descriptor. See ftruncate(2).
File locking commands for lockf.
Apply, test, or remove a POSIX lock on a section of a file. See lockf(3).
Get the parent process ID. See getppid(2).
Get the process group ID of a process. See getpgid(2).
Set the process group ID. See setpgid(2).
Get the process group ID of the calling process. See getpgrp(2).
Set the process group ID to the process ID. See setpgrp(3).
Get the effective user ID. See geteuid(2).
Get the effective group ID. See getegid(2).
Set the effective user ID. See seteuid(2).
Set the effective group ID. See setegid(2).
Set real and effective user IDs. See setreuid(2).
Set real and effective group IDs. See setregid(2).
Get the list of supplementary group IDs. See getgroups(2).
Set the supplementary group IDs. See setgroups(2).
Get system configuration value. See sysconf(3). Use sc_* constants.
Get path configuration value. See pathconf(3). Use pc_* constants.
Get path configuration value for an open file. See fpathconf(3).
Get configuration string value. See confstr(3). Use cs_* constants.
Test whether a file descriptor refers to a terminal. See isatty(3).
Get the name of a terminal device. See ttyname(3).
Thread-safe version of ttyname. See ttyname_r(3).
Get the pathname of the controlling terminal. See ctermid(3).
Get the foreground process group ID associated with a terminal. See tcgetpgrp(3).
Set the foreground process group ID associated with a terminal. See tcsetpgrp(3).
Get the system page size in bytes. See getpagesize(2).
Get the unique identifier of the current host. See gethostid(3).
Get the host name. See gethostname(2).
Set the host name. See sethostname(2).
Get the login name of the user. See getlogin(3).
Thread-safe version of getlogin. See getlogin_r(3).
Execute a program with specified arguments. See execv(2). Only returns on error (by raising an exception).
Execute a program with specified arguments and environment. See execve(2). Only returns on error (by raising an exception).
Execute a program using PATH to find the executable. See execvp(2). Only returns on error (by raising an exception).