tur/os
facts about the machine and the user running the program.
os/hostname names the machine; os/uid and os/gid the user and group the process runs as. Load with (load "stdlib/os.tur"). Every call returns (Result T IoError), with ENOSYS where a platform has no such notion.
Since: stdlib-os-surface P3
Uid
(defopaque Uid :int)
a numeric user id, as getuid(2) reports it.
Its own type rather than an :int, so a uid cannot be passed where a gid, a pid or a count is expected. uid->int gives the number for interop.
Since: stdlib-os-surface P3
Gid
(defopaque Gid :int)
a numeric group id, as getgid(2) reports it.
Since: stdlib-os-surface P3
uid->int
(uid->int [u :Uid] :int)
the number a Uid carries.
| u | a Uid |
The user id; 0 is root.
(= (uid->int u) 0) ; => true when running as root
Since: stdlib-os-surface P3
gid->int
(gid->int [g :Gid] :int)
the number a Gid carries.
| g | a Gid |
The group id.
(gid->int g) ; => 1000
Since: stdlib-os-surface P3
os/hostname
(os/hostname)
the name of this machine.
(Ok name) -- a fresh heap cstr the caller owns (release with free) -- or (Err e). gethostname(2) on POSIX; on Windows the DNS host name (GetComputerNameEx), which is what hostname.exe prints.
(match (os/hostname) (Ok h) (println h) (Err e) (println (io-error/message e)))
Since: stdlib-os-surface P3
os/uid
(os/uid)
the real user id of this process.
(Ok uid), or (Err e) with ENOSYS on Windows, which has no numeric user ids (it names users by SID).
(match (os/uid) (Ok u) (println (uid->int u)) (Err e) (println (io-error/message e)))
Since: stdlib-os-surface P3
os/gid
(os/gid)
the real group id of this process.
(Ok gid), or (Err e) with ENOSYS on Windows, which has no numeric group ids.
(match (os/gid) (Ok g) (println (gid->int g)) (Err e) (println (io-error/message e)))
Since: stdlib-os-surface P3