The Standard ML Basis Library


The Posix.ProcEnv structure

The structure Posix.ProcEnv specifies functions, as described in Section 4 of the POSIX standard [CITE]1003.1,1996/, that provide primitive POSIX access to the process environment.


Synopsis

signature POSIX_PROC_ENV
structure ProcEnv : POSIX_PROC_ENV

Interface

eqtype pid
eqtype uid
eqtype gid
eqtype file_desc
val uidToWord : uid -> SysWord.word
val wordToUid : SysWord.word -> uid
val gidToWord : gid -> SysWord.word
val wordToGid : SysWord.word -> gid
val getpid : unit -> pid
val getppid : unit -> pid
val getuid : unit -> uid
val geteuid : unit -> uid
val getgid : unit -> gid
val getegid : unit -> gid
val setuid : uid -> unit
val setgid : gid -> unit
val getgroups : unit -> gid list
val getlogin : unit -> string
val getpgrp : unit -> pid
val setsid : unit -> pid
val setpgid : {pid : pid option, pgid : pid option} -> unit
val uname : unit -> (string * string) list
val time : unit -> Time.time
val times : unit -> {elapsed : Time.time, utime : Time.time, stime : Time.time, cutime : Time.time, cstime : Time.time}
val getenv : string -> string option
val environ : unit -> string list
val ctermid : unit -> string
val ttyname : file_desc -> string
val isatty : file_desc -> bool
val sysconf : string -> SysWord.word

Description

eqtype pid

eqtype uid

eqtype gid

eqtype file_desc

uidToWord u
wordToUid i
convert between abstract user IDs and an underlying unique unsigned integers. Note that wordToUid does not ensure that i is a valid uid.

gidToWord g
wordToGid i
convert between abstract group IDs and an underlying unique unsigned integers. Note that wordToGid does not ensure that i is a valid gid.

getpid ()
returns the process ID of the calling process.

getppid ()
returns the parent process ID of the calling process.

getuid ()
returns the real user ID of the calling process.

geteuid ()
returns the effective user ID of the calling process.

getgid ()
returns the real group ID of the calling process.

getegid ()
returns the effective group ID of the calling process.

setuid u
sets the real user ID and effective user ID to u.

setgid g
sets the real group ID and effective group ID to g.

getgroups ()
returns the list of supplementary group IDs of the calling process.

getlogin ()
returns the user name associated with the calling process, i.e. the login name associated with the calling process.

getpgrp ()
returns the process group ID of the calling process.

setsid ()
creates a new session if the calling process is not a process group leader.

setpgid {pid, pgid}
sets the process group ID of the process with the process ID specified by pid to the process group ID specified by pgid. If pid is NONE, the process ID is taken to be the process ID of the calling process. If pgid is NONE, the process specified by pid becomes a process group leader.

uname ()
returns a list of pairs (name,value) including, at least, the names: "sysname", "nodename", "release", "version", and "machine". (A POSIX implementation may provide additional values beyond this set.) The respective values are strings that describe the named system component.

time ()
returns the elapsed wall time since the Epoch.

times ()
for the calling process, returns the wall time (elapsed), user time (utime), system time (stime), user CPU time of terminated child processes (cutime), and system CPU time of terminated child processes (cstime).

getenv name
searches the environment list for a string of the form name=value and returns SOME(value) if name is present; returns NONE if name is not present. This is equivalent to OS.Process.getEnv.

environ ()
returns the environment of the calling process as a list of strings.

ctermid ()
produces a string that represents the pathname of the controlling terminal for the calling process.

ttyname fd
produces a string that represents the pathname of the terminal associated with file descriptor fd. Raises OS.SysErr if fd does not denote a valid terminal device.

isatty fd
returns true if fd is a valid file descriptor associated with a terminal. Note that isatty will return false if fd is a bad file descriptor.

sysconf s
returns the integer value for the POSIX configurable system variable s. Raises OS.SysErr if s does not denote a supported POSIX system variable. Consult Section 4.8.1.2 of POSIX standard [CITE]1003.1,1996/ for a table of configurable system variables; this table is a minimal set required for POSIX compliance, and an implementation may extend it with non-POSIX variables.


See Also

Posix.ProcEnv, Posix.FileSys, Time, OS

[ INDEX | TOP | Parent | Root ]

Last Modified April 17, 1996
Comments to John Reppy.
Copyright © 1997 Bell Labs, Lucent Technologies