package shell
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=1e267e9120dc73c7dc94598f68b209622e64942f916dd1c1d3285f2a9fcab214
doc/shell.unix_extended/Unix_extended/index.html
Module Unix_extended
Source
Extensions to Core_unix
.
val fork_exec :
?stdin:Unix.File_descr.t ->
?stdout:Unix.File_descr.t ->
?stderr:Unix.File_descr.t ->
?path_lookup:bool ->
?env:
[ `Extend of (string * string) list | `Replace of (string * string) list ] ->
?working_dir:string ->
?setuid:int ->
?setgid:int ->
string ->
string list ->
Core.Pid.t
fork_exec prog args ~stdin ~stdout ~stderr ~setuid ~setgid
forks a new process that executes the program in file prog
, with arguments args
. The pid of the new process is returned immediately; the new process executes concurrently with the current process.
The function raises EPERM if when using set{gid,uid}
and the user id is not 0.
The standard input and outputs of the new process are connected to the descriptors stdin
, stdout
and stderr
.
The close_on_exec flag is cleared from stderr
stdout
and stdin
so it's safe to pass in fds with close_on_exec
set.
ERRORS: Unix.unix_error. This function should not raise EINTR; it will restart itself automatically.
RATIONAL: setuid
and setgid
do not do a full id drop (e.g.: they save the id in saved id) when the user does not have the privileges required to setuid to anyone.
By default all file descriptors should be set_closexec ASAP after being open to avoid being captured in parallel execution of fork_exec; resetting the closexec flag on the forked flag is a cleaner and more thread safe approach.
BUGS: The capabilities for setuid in linux are not tied to the uid 0 (man 7 capabilities). It is still fair to assume that under most system this capability is there IFF uid == 0. A more fine grain permissionning approach would make this function non-portable and be hard to implement in an async-signal-way.
Because this function keeps the lock for most of its lifespan and restarts automatically on EINTR it might prevent the OCaml signal handlers to run in that thread.
Network to host order long, like C.
Host to network order long, like C.
type statvfs = {
bsize : int;
(*file system block size
*)frsize : int;
(*fragment size
*)blocks : int;
(*size of fs in frsize units
*)bfree : int;
(*# free blocks
*)bavail : int;
(*# free blocks for non-root
*)files : int;
(*# inodes
*)ffree : int;
(*# free inodes
*)favail : int;
(*# free inodes for non-root
*)fsid : int;
(*file system ID
*)flag : int;
(*mount flags
*)namemax : int;
(*maximum filename length
*)
}
get load averages
The CIDR module moved into Core_unix