unix+x86_64 +linux

The unix module and its submodules provides support for functionality common to Unix-like systems.

Submodules

Index

Types

type gid = rt::gid_t;
type pid = rt::pid_t;
type pipe_flag = enum {
	NOCLOEXEC = rt::O_CLOEXEC,
	DIRECT = rt::O_DIRECT,
	NONBLOCK = rt::O_NONBLOCK,
};
type uid = rt::uid_t;

Functions

fn getegid() gid;
fn geteuid() uid;
fn getgid() gid;
fn getgroups() []gid;
fn getpgid(pid: pid) (pid | errors::noentry);
fn getpgrp() pid;
fn getpid() pid;
fn getppid() pid;
fn getpsid(pid: pid) (pid | errors::noentry | errors::noaccess);
fn getsid() pid;
fn getuid() uid;
fn nice(inc: int) (void | errors::error);
fn pipe(flags: pipe_flag = 0) ((io::file, io::file) | errors::error);
fn setegid(gid: gid) void;
fn seteuid(uid: uid) void;
fn setgid(gid: gid) void;
fn setgroups(gids: []gid) void;
fn setpgid(targ: pid, pgid: pid) (void | errors::error);
fn setsid() void;
fn setuid(uid: uid) void;
fn umask(mode: fs::mode) fs::mode;

Types

type gid[link]

type gid = rt::gid_t;

Group ID.

type pid[link]

type pid = rt::pid_t;

Process ID.

type pipe_flag[link]

type pipe_flag = enum {
	NOCLOEXEC = rt::O_CLOEXEC,
	DIRECT = rt::O_DIRECT,
	NONBLOCK = rt::O_NONBLOCK,
};

Flags to use for the io::files returned by pipe. Only NOCLOEXEC and NONBLOCK are guaranteed to be available.

type uid[link]

type uid = rt::uid_t;

User ID.

Functions

fn getegid[link]

fn getegid() gid;

Returns the current process effective group ID.

fn geteuid[link]

fn geteuid() uid;

Returns the current process effective user ID.

fn getgid[link]

fn getgid() gid;

Returns the current process group ID.

fn getgroups[link]

fn getgroups() []gid;

Returns a list of supplementary group IDs for the current process. The returned slice is statically allocated.

fn getpgid[link]

fn getpgid(pid: pid) (pid | errors::noentry);

Returns the process group associated with the given pid.

fn getpgrp[link]

fn getpgrp() pid;

Returns the current process group ID.

fn getpid[link]

fn getpid() pid;

Returns the current process ID.

fn getppid[link]

fn getppid() pid;

Returns the parent process ID.

fn getpsid[link]

fn getpsid(pid: pid) (pid | errors::noentry | errors::noaccess);

Returns the session ID associated with the given process.

fn getsid[link]

fn getsid() pid;

Returns the current process's session ID.

fn getuid[link]

fn getuid() uid;

Returns the current process user ID.

fn nice[link]

fn nice(inc: int) (void | errors::error);

Adds the argument to the niceness of the current process. The input should be between -20 and 19 (inclusive); lower numbers represent a higher priority. Generally, you must have elevated permissions to reduce your niceness, but not to increase it.

fn pipe[link]

fn pipe(flags: pipe_flag = 0) ((io::file, io::file) | errors::error);

Create a pair of two linked io::files, such that any data written to the second io::file may be read from the first.

fn setegid[link]

fn setegid(gid: gid) void;

Sets the caller's effective group ID to the specified value. This generally requires elevated permissions from the calling process.

If the system returns an error, this function will abort the program. Failing to handle errors from setegid is a grave security issue in your program, and therefore we require this function to succeed. If you need to handle the error case gracefully, call the appropriate syscall wrapper in rt:: yourself, and take extreme care to handle errors correctly.

fn seteuid[link]

fn seteuid(uid: uid) void;

Sets the caller's effective user ID to the specified value. This generally requires elevated permissions from the calling process.

If the system returns an error, this function will abort the program. Failing to handle errors from seteuid is a grave security issue in your program, and therefore we require this function to succeed. If you need to handle the error case gracefully, call the appropriate syscall wrapper in rt:: yourself, and take extreme care to handle errors correctly.

fn setgid[link]

fn setgid(gid: gid) void;

Sets the caller's group ID to the specified value. This generally requires elevated permissions from the calling process.

If the system returns an error, this function will abort the program. Failing to handle errors from setuid is a grave security issue in your program, and therefore we require this function to succeed. If you need to handle the error case gracefully, call the appropriate syscall wrapper in rt:: yourself, and take extreme care to handle errors correctly.

fn setgroups[link]

fn setgroups(gids: []gid) void;

Sets the list of supplementary group IDs which apply to the current process. This generally requires elevated permissions.

If the system returns an error, this function will abort the program. Failing to handle errors from setgroups is a grave security issue in your program, and therefore we require this function to succeed. If you need to handle the error case gracefully, call the appropriate syscall wrapper in rt:: yourself, and take extreme care to handle errors correctly.

fn setpgid[link]

fn setpgid(targ: pid, pgid: pid) (void | errors::error);

Sets the process group ID of the specified process. This function is error-prone; see the notes in the POSIX specification for its many caveats.

fn setsid[link]

fn setsid() void;

Creates a new session and sets the current process to the session leader. A new process group is also created with its process group ID equal to the pid of the current process, and the current process is made the process group leader.

Upon return, the new session will have no controlling terminal. To establish one, the caller must open a terminal file with fs::flag::CTTY; this opt-in approach differs from the Unix norm where O_NOCTTY is required to opt-out of establishing a controlling terminal.

The current process cannot be a process group leader; this is a programmer error and will cause a runtime assertion failure.

fn setuid[link]

fn setuid(uid: uid) void;

Sets the caller's user ID to the specified value. This generally requires elevated permissions from the calling process.

If the system returns an error, this function will abort the program. Failing to handle errors from setuid is a grave security issue in your program, and therefore we require this function to succeed. If you need to handle the error case gracefully, call the appropriate syscall wrapper in rt:: yourself, and take extreme care to handle errors correctly.

fn umask[link]

fn umask(mode: fs::mode) fs::mode;

Sets the file mode creation mask for the current process and return the previous value of the mask.