package posix-unistd
- Example
- Constants
- Basic I/O Operations
- Positioned I/O
- File Descriptor Operations
- Data Synchronization
- File Operations
- Directory Operations
- File Positioning
- File Permissions and Ownership
- File Locking
- Process Operations
- User and Group IDs
- Group Membership
- System Configuration
- Process Priority
- Sleep Operations
- Signal and Timer
- Terminal Operations
- System Information
- Login Information
- Program Execution
- Process Termination
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=2e05f3e890206138c4ebd09878359a2f
sha512=79a786c299b5d9f7f5ff0c3cf289539e8ea257b2068f75cd9faca9450679e5cd7de6b0fc5b77c9ddbbb5857d4f64119837a61a22d277e6e2a8ab4b3c4d5911c0
doc/posix-unistd/Posix_unistd/index.html
Module Posix_unistdSource
POSIX 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.
Example
(* 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_openConstants
Name limits
System configuration (sysconf) constants
Commonly available sysconf names
POSIX options
POSIX.2 constants
X/Open constants
Path configuration (pathconf) constants
File locking (lockf) commands
Configuration strings (confstr) constants
File positioning (lseek) constants
File access mode flags
Read permission
Write permission
Execute permission
File exists
Standard file descriptors
Basic I/O Operations
Read from a file descriptor.
See read(2).
Write to a file descriptor.
See write(2).
Positioned I/O
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).
File Descriptor Operations
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).
Data Synchronization
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).
File Operations
Create a symbolic link. See symlink(2).
Read the target of a symbolic link. See readlink(2).
Directory Operations
Change the current working directory to a directory referenced by a file descriptor. See fchdir(2).
File Positioning
Reposition the file offset. See lseek(2).
File Permissions and Ownership
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
File locking commands for lockf.
Apply, test, or remove a POSIX lock on a section of a file. See lockf(3).
Process Operations
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).
User and Group IDs
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).
Group Membership
Get the list of supplementary group IDs. See getgroups(2).
Set the supplementary group IDs. See setgroups(2).
System Configuration
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.
Process Priority
Sleep Operations
Signal and Timer
Terminal Operations
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).
System Information
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).
Login Information
Get the login name of the user. See getlogin(3).
Thread-safe version of getlogin. See getlogin_r(3).
Program Execution
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).
Process Termination
- Example
- Constants
- Basic I/O Operations
- Positioned I/O
- File Descriptor Operations
- Data Synchronization
- File Operations
- Directory Operations
- File Positioning
- File Permissions and Ownership
- File Locking
- Process Operations
- User and Group IDs
- Group Membership
- System Configuration
- Process Priority
- Sleep Operations
- Signal and Timer
- Terminal Operations
- System Information
- Login Information
- Program Execution
- Process Termination