Posix_unistdPOSIX 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_openRead 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 hard link. See link(2).
Create a symbolic link. See symlink(2).
Read the target of a symbolic link. See readlink(2).
Remove a file. See unlink(2).
Remove an empty directory. See rmdir(2).
Change the current working directory. See chdir(2).
Change the current working directory to a directory referenced by a file descriptor. See fchdir(2).
Get the current working directory. See getcwd(3).
File positioning commands for lseek.
val lseek : Unix.file_descr -> int -> seek_command -> intReposition the file offset. See lseek(2).
Access permission flags for access.
val access : string -> access_permission list -> boolCheck file accessibility. See access(2).
Change file ownership. See chown(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.
val lockf : Unix.file_descr -> lock_command -> int -> unitApply, test, or remove a POSIX lock on a section of a file. See lockf(3).
Create a new process. See fork(2).
Get the process ID of the calling process. See getpid(2).
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).
Create a new session. See setsid(2).
Get the session ID of a process. See getsid(2).
Get the real user ID. See getuid(2).
Get the effective user ID. See geteuid(2).
Get the real group ID. See getgid(2).
Get the effective group ID. See getegid(2).
Set the user ID. See setuid(2).
Set the effective user ID. See seteuid(2).
Set the group ID. See setgid(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.
Adjust process priority. See nice(2).
Sleep for a number of seconds. See sleep(3).
Sleep for a number of microseconds. See usleep(3).
Wait until a signal is caught. See pause(2).
Set an alarm clock. See alarm(2).
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).
Terminate the calling process immediately without cleanup. See _exit(2). Use Stdlib.exit for normal termination.