sys

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package sys exposes a cross-platform subset of operating-system / system-call functionality to rumo scripts. The same surface compiles for every target Go supports — including js/wasm — because it relies on the portable os and runtime packages plus a curated subset of the syscall package's Errno and Signal constants whose values are stable across linux, darwin, *bsd, windows and js/wasm.

Anything that is genuinely platform-specific (e.g. SIGHUP, SIGSEGV, raw system call numbers, ptrace, mmap, …) is intentionally omitted so the bytecode produced by `rumo build` stays portable.

Index

Constants

This section is empty.

Variables

View Source
var Module = module.NewBuiltin().
	Func("os() (value string)        target operating system (runtime.GOOS)", func() string { return runtime.GOOS }).
	Func("arch() (value string)      target architecture (runtime.GOARCH)", func() string { return runtime.GOARCH }).
	Func("compiler() (value string)    Go compiler used to build the host (gc/gccgo)", func() string { return runtime.Compiler }).
	Func("go_version() (value string)  Go runtime version", func() string { return runtime.Version() }).
	Func("num_cpu() (value int)        number of logical CPUs available", runtime.NumCPU).
	Func("num_goroutine() (value int)  number of currently running goroutines", runtime.NumGoroutine).
	Func("page_size() (value int)      memory page size in bytes", os.Getpagesize).
	Func("getpid() (pid int)              calling process id", os.Getpid).
	Func("getppid() (ppid int)            parent process id", os.Getppid).
	Func("getuid() (uid int)              real user id (-1 if unsupported)", os.Getuid).
	Func("geteuid() (euid int)            effective user id (-1 if unsupported)", os.Geteuid).
	Func("getgid() (gid int)              real group id (-1 if unsupported)", os.Getgid).
	Func("getegid() (egid int)            effective group id (-1 if unsupported)", os.Getegid).
	Func("getgroups() (gids []int, err error)  supplementary group ids", os.Getgroups).
	Func("hostname() (name string, err error)  host name reported by the kernel", os.Hostname).
	Func("getwd() (dir string, err error)      current working directory", os.Getwd).
	Func("getenv(key string) (value string)                     value of an env var ('' if unset)", osGetenv).
	Func("setenv(key string, value string) error                set an env var", osSetenv).
	Func("unsetenv(key string) error                            remove an env var", osUnsetenv).
	Func("clearenv()                                            remove every env var", osClearenv).
	Func("environ() (env []string)                              all 'KEY=VAL' env entries", os.Environ).
	Func("lookup_env(key string) (value string, found bool)     env var with explicit presence flag", osLookupEnv).
	Func("expand_env(s string) (result string)                  ${var}/$var substitution against the current env", osExpandEnv).
	Func("exit(code int)  terminate the host process immediately", osExit).
	Const("EPERM int", int64(syscall.EPERM)).
	Const("ENOENT int", int64(syscall.ENOENT)).
	Const("ESRCH int", int64(syscall.ESRCH)).
	Const("EINTR int", int64(syscall.EINTR)).
	Const("EIO int", int64(syscall.EIO)).
	Const("ENXIO int", int64(syscall.ENXIO)).
	Const("E2BIG int", int64(syscall.E2BIG)).
	Const("EBADF int", int64(syscall.EBADF)).
	Const("EAGAIN int", int64(syscall.EAGAIN)).
	Const("ENOMEM int", int64(syscall.ENOMEM)).
	Const("EACCES int", int64(syscall.EACCES)).
	Const("EFAULT int", int64(syscall.EFAULT)).
	Const("EBUSY int", int64(syscall.EBUSY)).
	Const("EEXIST int", int64(syscall.EEXIST)).
	Const("EXDEV int", int64(syscall.EXDEV)).
	Const("ENODEV int", int64(syscall.ENODEV)).
	Const("ENOTDIR int", int64(syscall.ENOTDIR)).
	Const("EISDIR int", int64(syscall.EISDIR)).
	Const("EINVAL int", int64(syscall.EINVAL)).
	Const("ENFILE int", int64(syscall.ENFILE)).
	Const("EMFILE int", int64(syscall.EMFILE)).
	Const("EFBIG int", int64(syscall.EFBIG)).
	Const("ENOSPC int", int64(syscall.ENOSPC)).
	Const("ESPIPE int", int64(syscall.ESPIPE)).
	Const("EROFS int", int64(syscall.EROFS)).
	Const("EMLINK int", int64(syscall.EMLINK)).
	Const("EPIPE int", int64(syscall.EPIPE)).
	Const("ENAMETOOLONG int", int64(syscall.ENAMETOOLONG)).
	Const("ENOSYS int", int64(syscall.ENOSYS)).
	Const("ENOTEMPTY int", int64(syscall.ENOTEMPTY)).
	Const("ELOOP int", int64(syscall.ELOOP)).
	Const("ETIMEDOUT int", int64(syscall.ETIMEDOUT)).
	Const("ECONNREFUSED int", int64(syscall.ECONNREFUSED)).
	Const("ECONNRESET int", int64(syscall.ECONNRESET)).
	Const("EHOSTUNREACH int", int64(syscall.EHOSTUNREACH)).
	Const("ENETUNREACH int", int64(syscall.ENETUNREACH)).
	Const("EPROTONOSUPPORT int", int64(syscall.EPROTONOSUPPORT)).
	Const("EAFNOSUPPORT int", int64(syscall.EAFNOSUPPORT)).
	Const("EADDRINUSE int", int64(syscall.EADDRINUSE)).
	Const("EADDRNOTAVAIL int", int64(syscall.EADDRNOTAVAIL)).
	Const("ENOTSOCK int", int64(syscall.ENOTSOCK)).
	Const("EALREADY int", int64(syscall.EALREADY)).
	Const("EINPROGRESS int", int64(syscall.EINPROGRESS)).
	Const("EISCONN int", int64(syscall.EISCONN)).
	Const("ENOTCONN int", int64(syscall.ENOTCONN)).
	Const("EMSGSIZE int", int64(syscall.EMSGSIZE)).
	Func("errno_str(errno int) (msg string)  human-readable error string for the given errno", sysErrnoStr).
	Const("SIGHUP int", int64(1)).
	Const("SIGINT int", int64(2)).
	Const("SIGQUIT int", int64(3)).
	Const("SIGILL int", int64(4)).
	Const("SIGTRAP int", int64(5)).
	Const("SIGABRT int", int64(6)).
	Const("SIGFPE int", int64(8)).
	Const("SIGKILL int", int64(9)).
	Const("SIGSEGV int", int64(11)).
	Const("SIGPIPE int", int64(13)).
	Const("SIGALRM int", int64(14)).
	Const("SIGTERM int", int64(15)).
	Func("kill(pid int, sig int) error  send a signal to a process", sysKill)

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL