package shell

  1. Overview
  2. Docs
Yet another implementation of fork&exec and related functionality

Install

Dune Dependency

Authors

Maintainers

Sources

shell-v0.14.0.tar.gz
sha256=dea47dfd44f8dd736b6ea0394bad5e9302c65c4c7243e73be2e05fe4381aef4f
md5=a91101aef477f2bd563c24f218ae0bd3

doc/shell.unix_extended/Unix_extended/index.html

Module Unix_extendedSource

Extensions to Core.Unix.

Sourceval fork_exec : ?stdin:Core.Unix.File_descr.t -> ?stdout:Core.Unix.File_descr.t -> ?stderr:Core.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.

  • parameter path_lookup

    if true than we use PATH to find the process to exec. @env specifies the environment the process runs in

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.

Sourceval seteuid : int -> unit
Sourceval setreuid : uid:int -> euid:int -> unit
Sourceval ntohl : Core.Int32.t -> Core.Int32.t

Network to host order long, like C.

Sourceval htonl : Core.Int32.t -> Core.Int32.t

Host to network order long, like C.

Sourcetype statvfs = {
  1. bsize : int;
    (*

    file system block size

    *)
  2. frsize : int;
    (*

    fragment size

    *)
  3. blocks : int;
    (*

    size of fs in frsize units

    *)
  4. bfree : int;
    (*

    # free blocks

    *)
  5. bavail : int;
    (*

    # free blocks for non-root

    *)
  6. files : int;
    (*

    # inodes

    *)
  7. ffree : int;
    (*

    # free inodes

    *)
  8. favail : int;
    (*

    # free inodes for non-root

    *)
  9. fsid : int;
    (*

    file system ID

    *)
  10. flag : int;
    (*

    mount flags

    *)
  11. namemax : int;
    (*

    maximum filename length

    *)
}
Sourceval sexp_of_statvfs : statvfs -> Ppx_sexp_conv_lib.Sexp.t
Sourceval statvfs_of_sexp : Ppx_sexp_conv_lib.Sexp.t -> statvfs
Sourceval bin_shape_statvfs : Core.Bin_prot.Shape.t
Sourceval bin_size_statvfs : statvfs Core.Bin_prot.Size.sizer
Sourceval bin_write_statvfs : statvfs Core.Bin_prot.Write.writer
Sourceval bin_writer_statvfs : statvfs Core.Bin_prot.Type_class.writer
Sourceval bin_read_statvfs : statvfs Core.Bin_prot.Read.reader
Sourceval __bin_read_statvfs__ : (int -> statvfs) Core.Bin_prot.Read.reader
Sourceval bin_reader_statvfs : statvfs Core.Bin_prot.Type_class.reader
Sourceval bin_statvfs : statvfs Core.Bin_prot.Type_class.t
Sourceval statvfs : string -> statvfs

get file system statistics

Sourceval getloadavg : unit -> float * float * float

get load averages

Sourcemodule Extended_passwd : sig ... end
Sourceval strptime : fmt:string -> string -> Core.Unix.tm
  • deprecated [since 2019-07] use Core.Unix.strptime

The CIDR module moved into Core.Unix

Sourcemodule Inet_port : sig ... end

Simple int wrapper to be explicit about ports.

Sourcemodule Mac_address : sig ... end
Sourcemodule Quota : sig ... end
Sourcemodule Mount_entry : sig ... end
Sourceval terminal_width : int Core.Lazy.t
OCaml

Innovation. Community. Security.