All Classes Namespaces Functions Variables Groups Pages
Library Functions

## Functions

nothing | Qore::abort ()
| Aborts the current program (this function does not return) More...
string | Qore::basename (string path)
| Returns a string giving the last element of a file path (meant to be the filename) More...
nothing | Qore::basename ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
nothing | Qore::close_all_fd (*softbool strd)
| closes all possible file descriptors; useful in "daemon" processes that may have inherited open file descriptors More...
string | Qore::dirname (string path)
| Returns a string giving the path up to a file but not the filename itself. More...
nothing | Qore::dirname ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
int | Qore::errno ()
| Returns the error code of the last error that occurred in the current thread. More...
nothing | Qore::exec (string command)
| Replaces the current process image with another; this function does not return. More...
nothing | Qore::exit (softint rc=0)
| Exits the program with the return code passed (this function does not return) More...
int | Qore::fork ()
| Creates a copy of the current process with a new PID; returns 0 in the child process; returns the child's PID in the parent process. More...
list | Qore::getaddrinfo (*string node, *softstring service, softint family=AF_UNSPEC, softint flags=0)
| Returns a list of Address Information Hash for the given node name or string address; if no lookup can be performed then an exception is thrown. More...
int | Qore::getegid ()
| Returns the effective group ID of the current process. More...
int | Qore::geteuid ()
| Returns the effective user ID of the current process. More...
int | Qore::getgid ()
| Returns the real group ID of the current process. More...
list | Qore::getgroups ()
| returns a list of group IDs that the user is a member of More...
*string | Qore::gethostbyaddr (string addr, softint type=AF_INET)
| Returns the official hostname corresponding to the network addressed passed as an argument. More...
nothing | Qore::gethostbyaddr ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
*hash | Qore::gethostbyaddr_long (string addr, softint type=AF_INET)
| Returns a hash representing all host and address information corresponding to the address and address type passed as arguments. More...
nothing | Qore::gethostbyaddr_long ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
*string | Qore::gethostbyname (string name)
| Returns the first address corresponding to the hostname passed as an argument or NOTHING if the lookup fails. More...
nothing | Qore::gethostbyname ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
*hash | Qore::gethostbyname_long (string name)
| Returns a hash representing all host and address information corresponding to the hostname passed as an argument. More...
nothing | Qore::gethostbyname_long ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
string | Qore::gethostname ()
| Returns the hostname of the system. More...
int | Qore::getpid ()
| Returns the PID (process ID) of the current process. More...
int | Qore::getppid ()
| Returns the PID (process ID) of the parent process of the current process. More...
int | Qore::getuid ()
| Returns the real user ID of the current process. More...
int | Qore::kill (softint pid, softint sig=SIGHUP)
| Sends a signal to a process, if no signal number is given, then Qore::SIGHUP is sent by default. More...
nothing | Qore::kill ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
int | Qore::rand ()
| Returns a random 64-bit integer number. More...
int | Qore::setegid (softint gid)
| Changes the process effective group ID according to the argument passed. More...
int | Qore::seteuid (softint uid)
| Changes the effective process user ID according to the argument passed. More...
int | Qore::setgid (softint gid)
| Changes the process group ID according to the argument passed. More...
nothing | Qore::setgroups (softlist gids)
| sets the list of supplementary group IDs for the current process More...
int | Qore::setsid ()
| Creates a new session lead by the calling process. More...
int | Qore::setuid (softint uid)
| Changes the process user ID according to the argument passed. More...
int | Qore::sleep (softint seconds)
| Causes the current thread to sleep for a certain number of seconds. More...
nothing | Qore::sleep ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
nothing | Qore::srand (softint seed)
| Seeds the random number generator with the integer passed. More...
nothing | Qore::srand ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
string | Qore::strerror (softint err)
| Returns the string corresponding to the error code passed (generally retrieved with errno()) More...
string | Qore::strerror ()
| Returns the string corresponding to the last error that occurred in the current thread. More...
int | Qore::system (string command)
| executes a command and returns the exit code of the process More...
nothing | Qore::system ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
int | Qore::usleep (softint usecs)
| Causes the current thread to sleep for a certain number of microseconds. More...
int | Qore::usleep (date d)
| Causes the current thread to sleep for a certain number of microseconds. More...
nothing | Qore::usleep ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...

## Detailed Description

Library functions

# Host Information Hash

Key | Type | Description
`name` | string | The official fully-qualified name of the host
`aliases` | list of string | Any hostname aliases for the host
`typename` | string | The type of network address (either `"ipv4"` or `"ipv6"`)
`type` | int | One of the Network Address Family Constants (either Qore::AF_INET or Qore::AF_INET6) corresponding to the type of network addresses given
`len` | int | The length of the addresses in bytes when represented in binary form
`addresses` | list of string | All addresses corresponding to the host; the list should have at least 1 element

# Address Information Hash

Key | Type | Description
`address` | string | A valid address of the host, for example: `"::1"`.
`address_desc` | string | A descriptive string of the address containing the address family, for example: `"ipv6[::1]"`
`family` | int | The network address family; see Network Address Family Constants.
`familystr` | string | A descriptive string for the network address family, for example: `"ipv6"`.
`addrlen` | int | The length of the internal network address data structure (not normally needed in Qore but provided anyway)
[`port`] | int | The port number corresponding to the service (if applicable)

## Function Documentation

nothing Qore::abort | ( |  | ) |

Aborts the current program (this function does not return)

This function causes the current process to terminate abnormally; a core dump or crash report may be generated if enabled

Restrictions:
  Qore::PO_NO_PROCESS_CONTROL

Example:
  abort();

See Also
  exit()

string Qore::basename | ( | string | path | ) |

Returns a string giving the last element of a file path (meant to be the filename)

Code Flags:
  CONSTANT

Parameters

  path | the path to process

Returns
  a string giving the last element of the given file path (meant to be the filename)

Example:
  string fn = basename("/usr/local/bin/file_name");

See Also
  dirname()

nothing Qore::basename | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

nothing Qore::close_all_fd | ( | *softbool | strd | ) |

closes all possible file descriptors; useful in "daemon" processes that may have inherited open file descriptors

Platform Availability:
  Qore::Option::HAVE_CLOSE_ALL_FD

Restrictions:
  Qore::PO_NO_PROCESS_CONTROL

Parameters

  strd | if True then also stdin, stdout, and stderr are closed, otherwise fds > 2 are closed

Example:
  close_all_fd();

Note
  if there are file descriptors open by Qore when this function is called, this function will also close those file descriptors; normally this function should only be used when starting a new process after a fork() and exec() to close any inherited descriptors, for example

string Qore::dirname | ( | string | path | ) |

Returns a string giving the path up to a file but not the filename itself.

Code Flags:
  CONSTANT

Parameters

  path | the path to process

Returns
  a string giving the path up to a file but not the filename itself; if no directory separator characters can be found in the path, `"."` is returned (meaning the current directory)

Example:
  string dir = dirname("/usr/local/bin/file_name");

See Also
  basename()

nothing Qore::dirname | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

int Qore::errno | ( |  | ) |

Returns the error code of the last error that occurred in the current thread.

Returns
  the error code of the last error that occurred in the current thread (see Error Constants for possible error code values)

Example:
  if (unlink(path))
  printf("%s: %s\n", path, strerror(errno()));

See Also
  strerror() for a function that gives the string description for the error number returned by this function

nothing Qore::exec | ( | string | command | ) |

Replaces the current process image with another; this function does not return.

Restrictions:
  Qore::PO_NO_EXTERNAL_PROCESS, Qore::PO_NO_PROCESS_CONTROL

Parameters

  command | the executable to execute and any command-line arguments; the command is executed internally by a call to execvp() (3)

Example:
  exec("/usr/bin/xterm -bg black -fg white -sb -sl 2000");

nothing Qore::exit | ( | softint | rc = `0` | ) |

Exits the program with the return code passed (this function does not return)

Restrictions:
  Qore::PO_NO_PROCESS_CONTROL

Parameters

  rc | the return code for the process (0 = no error; success)

Example:
  exit(0);

See Also
  abort()

int Qore::fork | ( |  | ) |

Creates a copy of the current process with a new PID; returns 0 in the child process; returns the child's PID in the parent process.

This function will throw an `ILLEGAL-FORK` exception if more than one thread is running

Platform Availability:
  Qore::Option::HAVE_FORK

Restrictions:
  Qore::PO_NO_PROCESS_CONTROL

Returns
  0 in the child process; returns the child's PID in the parent process; if an error occurs, then -1 is returned, in this case no child process was started and the error number can be retrieved with the errno() function

Example:
  int pid;
  if (pid = fork())
  printf("child has PID %d\n", pid);

Exceptions

  ILLEGAL-FORK | Cannot fork if more than one thread is running

Note
  - after a fork(), the only safe call is exec(), many system calls are not async-signal safe, including pthread_create() which is used to start new threads.
  - the Qore process will crash if unsafe operations are called after a fork()
  - the signal-handling thread cannot be reliably started on many platforms (ex: FreeBSD) after a fork(), therefore signal handling is disabled in the child process after a fork()
  - on Darwin (OS/X) threading primitives are unusable in the child process after a fork()

list Qore::getaddrinfo | ( | *string | node,
|  | *softstring | service,
|  | softint | family = `AF_UNSPEC`,
|  | softint | flags = `0`
| ) |  |

Returns a list of Address Information Hash for the given node name or string address; if no lookup can be performed then an exception is thrown.

Either node or service may be NOTHING but not both or a `QOREADDRINFO-GETINFO-ERROR` exception will be thrown

Restrictions:
  Qore::PO_NO_EXTERNAL_INFO

Code Flags:
  RET_VALUE_ONLY

Parameters

  node | The host name or node name to look up
  service | The service name to look up to a port number
  family | The address family for the lookup, must be one of Qore::AF_INET, Qore::AF_INET6, or Qore::AF_UNSPEC, meaning to return all possible addresses
  flags | see Network Address Information Constants for possible values to be combined with binary or

Returns
  a list of Address Information Hash for the given node name or string address; if no lookup can be performed then an exception is thrown

Example:
  list l = getaddrinfo("localhost");

Exceptions

  QOREADDRINFO-GETINFO-ERROR | nodename nor servname provided, or not known

int Qore::getegid | ( |  | ) |

Returns the effective group ID of the current process.

Platform Availability:
  Qore::Option::HAVE_UNIX_USERMGT

Restrictions:
  Qore::PO_NO_EXTERNAL_INFO

Returns
  the effective group ID of the current process

Example:
  int egid = getegid();

int Qore::geteuid | ( |  | ) |

Returns the effective user ID of the current process.

Platform Availability:
  Qore::Option::HAVE_UNIX_USERMGT

Restrictions:
  Qore::PO_NO_EXTERNAL_INFO

Returns
  the effective user ID of the current process

Example:
  int euid = geteuid();

int Qore::getgid | ( |  | ) |

Returns the real group ID of the current process.

Platform Availability:
  Qore::Option::HAVE_UNIX_USERMGT

Restrictions:
  Qore::PO_NO_EXTERNAL_INFO

Returns
  the real group ID of the current process

Example:
  int gid = getgid();

list Qore::getgroups | ( |  | ) |

returns a list of group IDs that the user is a member of

Platform Availability:
  Qore::Option::HAVE_UNIX_USERMGT

Restrictions:
  Qore::PO_NO_EXTERNAL_INFO

Example:
  list l = getgroups();

Returns
  a list of group IDs that the user is a member of

Since
  Qore 0.8.11.1

*string Qore::gethostbyaddr | ( | string | addr,
|  | softint | type = `AF_INET`
| ) |  |

Returns the official hostname corresponding to the network addressed passed as an argument.

If the address family is invalid or the address string is not a valid address for the given family a `GETHOSTBYADDR-ERROR` exception will be thrown.

Restrictions:
  Qore::PO_NO_EXTERNAL_INFO

Code Flags:
  CONSTANT

Parameters

  addr | the address to look up
  type | the network address family; see Network Address Family Constants for valid values

Returns
  the official hostname corresponding to the network addressed passed as an argument

Example:
  *string hostname = gethostbyaddr("192.168.0.33");
  if (!exists hostname)
  printf("address lookup on 192.168.0.33 failed\n", host);

Exceptions

  GETHOSTBYADDR-ERROR | invalid address for the given family or invalid address family

See Also
  gethostbyaddr_long() for a version of this function that returns all host information, including all hostname aliases and all addresses

nothing Qore::gethostbyaddr | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

*hash Qore::gethostbyaddr_long | ( | string | addr,
|  | softint | type = `AF_INET`
| ) |  |

Returns a hash representing all host and address information corresponding to the address and address type passed as arguments.

If the address family is invalid or the address string is not a valid address for the given family a `GETHOSTBYADDR-ERROR` exception will be thrown.

Restrictions:
  Qore::PO_NO_EXTERNAL_INFO

Code Flags:
  CONSTANT

Parameters

  addr | the address to look up
  type | the network address family; see Network Address Family Constants for valid values

Returns
  a hash representing all host and address information corresponding to the address and address type passed as arguments

Example:
  *hash ah = gethostbyaddr_long("192.168.0.33");
  if (!exists ah)
  printf("address lookup on 192.168.0.33 failed\n", host);

Exceptions

  GETHOSTBYADDR-ERROR | invalid address for the given family or invalid address family

See Also
  gethostbyaddr() for a simpler version of this function that returns just a single hostname for the address

nothing Qore::gethostbyaddr_long | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

*string Qore::gethostbyname | ( | string | name | ) |

Returns the first address corresponding to the hostname passed as an argument or NOTHING if the lookup fails.

Restrictions:
  Qore::PO_NO_EXTERNAL_INFO

Code Flags:
  CONSTANT

Parameters

  name | the name to look up

Returns
  the first address corresponding to the hostname passed as an argument or NOTHING if the lookup fails

Example:
  *string addr = gethostbyname(host);
  if (!exists host)
  printf("address lookup on %y failed; hostname unknown\n", host);

See Also
  gethostbyname_long() for a version of this function that returns all host information, including all hostname aliases and all addresses

nothing Qore::gethostbyname | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

*hash Qore::gethostbyname_long | ( | string | name | ) |

Returns a hash representing all host and address information corresponding to the hostname passed as an argument.

Restrictions:
  Qore::PO_NO_EXTERNAL_INFO

Code Flags:
  CONSTANT

Parameters

  name | the name to look up

Returns
  a hash representing all host and address information corresponding to the hostname passed as an argument

Example:
  *hash ah = gethostbyname_long(host);
  if (!exists host)
  printf("address lookup on %y failed; hostname unknown\n", host);

See Also
  gethostbyname() for a version of this function that returns just the first network address corresponding to the hostname

nothing Qore::gethostbyname_long | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

string Qore::gethostname | ( |  | ) |

Returns the hostname of the system.

Returns
  the hostname of the system

Restrictions:
  Qore::PO_NO_EXTERNAL_INFO

Code Flags:
  CONSTANT

Example:
  string host = gethostname();

int Qore::getpid | ( |  | ) |

Returns the PID (process ID) of the current process.

Returns
  the PID (process ID) of the current process

Restrictions:
  Qore::PO_NO_EXTERNAL_INFO

Code Flags:
  RET_VALUE_ONLY

Example:
  int pid = getpid();

int Qore::getppid | ( |  | ) |

Returns the PID (process ID) of the parent process of the current process.

Platform Availability:
  Qore::Option::HAVE_GETPPID

Restrictions:
  Qore::PO_NO_EXTERNAL_INFO

Code Flags:
  RET_VALUE_ONLY

Returns
  the PID (process ID) of the parent process of the current process

Example:
  int ppid = HAVE_GETPPID ? getppid() : -1;

int Qore::getuid | ( |  | ) |

Returns the real user ID of the current process.

Platform Availability:
  Qore::Option::HAVE_UNIX_USERMGT

Restrictions:
  Qore::PO_NO_EXTERNAL_INFO

Returns
  the real user ID of the current process

Example:
  int uid = getuid();

int Qore::kill | ( | softint | pid,
|  | softint | sig = `SIGHUP`
| ) |  |

Sends a signal to a process, if no signal number is given, then Qore::SIGHUP is sent by default.

Platform Availability:
  Qore::Option::HAVE_KILL

Restrictions:
  Qore::PO_NO_EXTERNAL_PROCESS

Parameters

  pid

  the pid argument can have the following interpretations:
  - `> 0`: the signal is sent to the process ID given
  - `0`: the signal is sent to all processes whose group ID is equal to the process group ID of the sender, and for which the process has permission
  - `-1`: if the user has super-user privileges, the signal is sent to all processes excluding system processes and the process sending the signal. If the user is not the super user, the signal is sent to all processes with the same uid as the user, excluding the process sending the signal. No error is returned if any process could be signaled.

  sig | the signal number to send to the process or processes

Returns
  0 means success (no error), or -1 meaning an error occurred; in this case check errno() for the error

Example:
  if (kill(pid, SIGTERM))
  printf("error sending signal to pid %d: %s\n", pid, strerror());

nothing Qore::kill | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Restrictions:
  Qore::PO_NO_EXTERNAL_PROCESS

Code Flags:
  RUNTIME_NOOP

int Qore::rand | ( |  | ) |

Returns a random 64-bit integer number.

This function uses the C library function random() to generate the number if available on the current platform, otherwise uses rand().

Returns
  a random 64-bit integer number

Code Flags:
  CONSTANT

Example:
  int num = rand();

See Also
  srand() for a function to seed the random number generator

int Qore::setegid | ( | softint | gid | ) |

Changes the process effective group ID according to the argument passed.

Platform Availability:
  Qore::Option::HAVE_UNIX_USERMGT

Restrictions:
  Qore::PO_NO_PROCESS_CONTROL

Parameters

  gid | the group ID to set

Returns
  0 if no error occurred; -1 if an error occurred, in which case errno() and/or strerror() can be used to retrieve the error

Example:
  if (setegid(gid))
  printf("setegid %d: %s\n", gid, strerror());

int Qore::seteuid | ( | softint | uid | ) |

Changes the effective process user ID according to the argument passed.

Platform Availability:
  Qore::Option::HAVE_SETEUID

Restrictions:
  Qore::PO_NO_PROCESS_CONTROL

Parameters

  uid | the user ID to set

Returns
  0 if no error occurred; -1 if an error occurred, in which case errno() and/or strerror() can be used to retrieve the error

Example:
  if (seteuid(uid))
  printf("seteuid %d: %s\n", uid, strerror());

int Qore::setgid | ( | softint | gid | ) |

Changes the process group ID according to the argument passed.

Platform Availability:
  Qore::Option::HAVE_UNIX_USERMGT

Restrictions:
  Qore::PO_NO_PROCESS_CONTROL

Parameters

  gid | the group ID to set

Returns
  0 if no error occurred; -1 if an error occurred, in which case errno() and/or strerror() can be used to retrieve the error

Example:
  if (setgid(gid))
  printf("setgid %d: %s\n", gid, strerror());

nothing Qore::setgroups | ( | softlist | gids | ) |

sets the list of supplementary group IDs for the current process

Platform Availability:
  Qore::Option::HAVE_UNIX_USERMGT

Restrictions:
  Qore::PO_NO_PROCESS_CONTROL

Example:
  setgroups(l);

Parameters

  gids | a list of supplementary group IDs for the current process

Since
  Qore 0.8.11.1

int Qore::setsid | ( |  | ) |

Creates a new session lead by the calling process.

The calling process is the session leader of the new session, is the process group leader of a new process group and has no controlling terminal. The calling process is the only process in either the session or the process group.

Returns
  Upon successful completion, the setsid() function returns the value of the process group ID of the new process group, which is the same as the process ID of the calling process; if an error occurs, setsid() returns -1 and errno() and/or strerror() can be used to check the error.

Restrictions:
  Qore::PO_NO_PROCESS_CONTROL

Example:
  if (setsid() == -1)
  printf("setsid(): %s\n", strerror());

int Qore::setuid | ( | softint | uid | ) |

Changes the process user ID according to the argument passed.

Platform Availability:
  Qore::Option::HAVE_UNIX_USERMGT

Restrictions:
  Qore::PO_NO_PROCESS_CONTROL

Parameters

  uid | the user ID to set

Returns
  0 if no error occurred; -1 if an error occurred, in which case errno() and/or strerror() can be used to retrieve the error

Example:
  if (setuid(uid))
  printf("setuid %d: %s\n", uid, strerror());

int Qore::sleep | ( | softint | seconds | ) |

Causes the current thread to sleep for a certain number of seconds.

Restrictions:
  Qore::PO_NO_PROCESS_CONTROL

Parameters

  seconds | The amount of time in seconds to sleep; integer arguments are interpreted literally as a number of seconds to sleep, however a relative date/time value can be given instead of an integer to make the source more readable (ex: `5s`), however as this function only supports a resolution of 1 second, milliseconds and microseconds are ignored if passed in a relative date/time value

Returns
  should always return 0 for success

Example:
  sleep(10s);

See Also
  usleep() for a similar function supporting microsecond resolution

nothing Qore::sleep | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Restrictions:
  Qore::PO_NO_PROCESS_CONTROL

Code Flags:
  RUNTIME_NOOP

nothing Qore::srand | ( | softint | seed | ) |

Seeds the random number generator with the integer passed.

This function uses the C library function srandom() if available on the current platform, otherwise uses srand()

Restrictions:
  Qore::PO_NO_PROCESS_CONTROL

Parameters

  seed | the seed for the random number generator (only the least-significant 32-bits are used)

Example:
  srand(now());

nothing Qore::srand | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Restrictions:
  Qore::PO_NO_PROCESS_CONTROL

Code Flags:
  RUNTIME_NOOP

string Qore::strerror | ( | softint | err | ) |

Returns the string corresponding to the error code passed (generally retrieved with errno())

Code Flags:
  CONSTANT

Parameters

  err | the error code to retrieve the description for (generally provided by errno())

Returns
  the string corresponding to the error code passed; if the error code is unknown, then a string like `"Unknown error: -1"` is returned

Example:
  if (unlink(path))
  printf("%s: %s\n", path, strerror(errno()));

string Qore::strerror | ( |  | ) |

Returns the string corresponding to the last error that occurred in the current thread.

Returns
  the string corresponding to the last error that occurred in the current thread

Code Flags:
  CONSTANT

Example:
  if (unlink(path))
  printf("%s: %s\n", path, strerror());

Since
  Qore 0.8.4 this variant of the function automatically uses the last error value for the current thread

int Qore::system | ( | string | command | ) |

executes a command and returns the exit code of the process

Platform Availability:
  Qore::Option::HAVE_SYSTEM

Restrictions:
  Qore::PO_NO_EXTERNAL_PROCESS

Parameters

  command | the command to execute with system() (3)

Returns
  the exit code of the process executed

Example:
  int rc = system("ls -l");

See Also
  - backquote()
  - the backquote operator

nothing Qore::system | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Restrictions:
  Qore::PO_NO_EXTERNAL_PROCESS

Code Flags:
  RUNTIME_NOOP

int Qore::usleep | ( | softint | usecs | ) |

Causes the current thread to sleep for a certain number of microseconds.

Restrictions:
  Qore::PO_NO_PROCESS_CONTROL

Parameters

  usecs | The amount of time in microseconds to sleep; integer arguments are interpreted literally as a number of microseconds to sleep

Returns
  should always return 0 for success

Example:
  usleep(5000);

See Also
  sleep() for a similar function supporting second resolution

Note
  both sleep() and usleep() are implemented internally by calls to nanosleep() (2) if available on the current platform, otherwise both are implemented by calls to usleep() (3)

int Qore::usleep | ( | date | d | ) |

Causes the current thread to sleep for a certain number of microseconds.

Restrictions:
  Qore::PO_NO_PROCESS_CONTROL

Parameters

  d | A time value giving the amount of time in microseconds to sleep; this should be a relative date/time value to make the source more readable (ex: `250ms`)

Returns
  should always return 0 for success

Example:
  usleep(250ms);

See Also
  sleep() for a similar function supporting second resolution

Note
  both sleep() and usleep() are implemented internally by calls to nanosleep() (2) if available on the current platform, otherwise both are implemented by calls to usleep() (3)

nothing Qore::usleep | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Restrictions:
  Qore::PO_NO_PROCESS_CONTROL

Code Flags:
  RUNTIME_NOOP