Module posix.sys
Functions
euidaccess (file, mode) | Check permissions like access , but for euid. |
pipeline_iterator (t, pipe_fn) | Perform a series of commands and Lua functions as a pipeline,
returning the output of the last stage's stdout as
the values of an iterator. |
pipeline_slurp (t, pipe_fn) | Perform a series of commands and Lua functions as a pipeline,
returning the output of the last stage's stdout . |
spawn (task, ...) | Run a command or function in a sub-process. |
timeradd (x, y) | Add one gettimeofday() returned timeval to another. |
timercmp (x, y) | Compare one gettimeofday() returned timeval with another |
timersub (x, y) | Subtract one gettimeofday() returned timeval from another. |
Functions
- euidaccess (file, mode)
-
Check permissions like
access
, but for euid. Based on the glibc function of the same name. Does not always check for read-only file system, text busy, etc., and does not work with ACLs &c.Parameters:
- file file to check
- mode checks to perform (as for access)
Returns:
-
0 if access allowed;
nil
otherwise (and errno is set) - pipeline_iterator (t, pipe_fn)
-
Perform a series of commands and Lua functions as a pipeline,
returning the output of the last stage's
stdout
as the values of an iterator.Parameters:
- t
as for
posix.pipeline
- pipe_fn
as for
posix.pipeline
Returns:
-
iterator function returning a chunk of output on each call
- t
as for
- pipeline_slurp (t, pipe_fn)
-
Perform a series of commands and Lua functions as a pipeline,
returning the output of the last stage's
stdout
.Parameters:
- t
as for
posix.pipeline
- pipe_fn
as for
posix.pipeline
Returns:
-
output of the pipeline
- t
as for
- spawn (task, ...)
-
Run a command or function in a sub-process.
Parameters:
- task
, a string to be executed as a shell command, or a
table of arguments to
posix.execp
or a Lua function which should read from standard input, write to standard output, and return an exit code - ... positional arguments to the program or function
Returns:
- status exit code, or nil if fork or wait fails
- error message, or exit type if wait succeeds
- task
, a string to be executed as a shell command, or a
table of arguments to
- timeradd (x, y)
-
Add one gettimeofday() returned timeval to another.
Parameters:
- x a timeval
- y another timeval
Returns:
-
x + y, adjusted for usec overflow
- timercmp (x, y)
-
Compare one gettimeofday() returned timeval with another
Parameters:
- x a timeval
- y another timeval
Returns:
-
0 if x and y are equal, >0 if x is newer, <0 if y is newer
- timersub (x, y)
-
Subtract one gettimeofday() returned timeval from another.
Parameters:
- x a timeval
- y another timeval
Returns:
-
x - y, adjusted for usec underflow