luaposix 35.1 Reference

# Module `posix.stdlib`

Standard Posix Library functions.

## Functions

abort () | Abort the program immediately.
getenv ([name]) | Get value of environment variable, or all variables.
grantpt (fd) | Grant access to a slave pseudoterminal
mkdtemp (templ) | Create a unique temporary directory.
mkstemp (templ) | Create a unique temporary file.
openpt (oflags) | Open a pseudoterminal.
ptsname (fd) | Get the name of a slave pseudo-terminal
realpath (path) | Find canonicalized absolute pathname.
setenv (name[, value[, overwrite]]) | Set an environment variable for this process.
unlockpt (fd) | Unlock a pseudoterminal master/slave pair

## Functions

abort ()
  Abort the program immediately.

  ### See also:

  abort(3)
getenv ([name])
  Get value of environment variable, or all variables.

  ### Parameters:

  - name string if nil, get all (optional)

  ### Returns:

  value if name given, otherwise a name-indexed table of values.

  ### See also:

  getenv(3)

  ### Usage:

      for a,b in pairs(posix.getenv()) do print(a, b) end

grantpt (fd)
  Grant access to a slave pseudoterminal

  ### Parameters:

  - fd int descriptor returned by openpt

  ### Returns:

  int `0`, if successful

  ### Or

  1. nil
  2. string error message
  3. int errnum

  ### See also:

  - grantpt(3)
  - openpt
  - ptsname
  - unlockpt
mkdtemp (templ)
  Create a unique temporary directory.

  ### Parameters:

  - templ string pattern that ends in six 'X' characters

  ### Returns:

  string path to directory, if successful

  ### Or

  1. nil
  2. string error message
  3. int errnum

  ### See also:

  mkdtemp(3)
mkstemp (templ)
  Create a unique temporary file.

  ### Parameters:

  - templ string pattern that ends in six 'X' characters

  ### Returns:

  1. int open file descriptor
  2. string path to file, if successful

  ### Or

  1. nil
  2. string error message
  3. int errnum

  ### See also:

  mkstemp(3)

  ### Usage:

      local stdlib = require "posix.stdlib"
      stdlib.mkstemp 'wooXXXXXX'

openpt (oflags)
  Open a pseudoterminal.

  ### Parameters:

  - oflags int bitwise OR of zero or more of `O_RDWR` and `O_NOCTTY`

  ### Returns:

  file descriptor of pseudoterminal, if successful

  ### Or

  1. nil
  2. string error message
  3. int errnum

  ### See also:

  - posix_openpt(3)
  - grantpt
  - ptsname
  - unlockpt
ptsname (fd)
  Get the name of a slave pseudo-terminal

  ### Parameters:

  - fd int descriptor returned by openpt

  ### Returns:

  path name of the slave terminal device, if successful

  ### Or

  1. nil
  2. string error message
  3. int errnum

  ### See also:

  - ptsname(3)
  - grantpt
  - unlockpt
realpath (path)
  Find canonicalized absolute pathname.

  ### Parameters:

  - path string file to act on

  ### Returns:

  string canonicalized absolute path, if successful

  ### Or

  1. nil
  2. string error messag
  3. int errnum

  ### See also:

  realpath(3)
setenv (name[, value[, overwrite]])
  Set an environment variable for this process. (Child processes will inherit this)

  ### Parameters:

  - name string
  - value string (maybe nil, meaning 'unset') (optional)
  - overwrite non-nil prevents overwriting a variable (optional)

  ### Returns:

  int `0`, if successful

  ### Or

  1. nil
  2. string error message
  3. int errnum

  ### See also:

  setenv(3)
unlockpt (fd)
  Unlock a pseudoterminal master/slave pair

  ### Parameters:

  - fd int descriptor returned by openpt

  ### Returns:

  int `0`, if successful

  ### Or

  1. nil
  2. string error message
  3. int errnum

  ### See also:

  - unlockpt(3)
  - openpt
  - ptsname
  - grantpt

generated by LDoc 1.4.6 Last updated 2021-09-09 17:41:28