Qore Programming Language Reference Manual  0.9.2
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< hash< NetIfInfo > > Qore::get_netif_list ()
 returns a list of network interfaces 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 address 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 non-negative 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

◆ abort()

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:
See also
exit()

◆ basename() [1/2]

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
paththe 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()

◆ basename() [2/2]

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

◆ close_all_fd()

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
strdif True then also stdin, stdout, and stderr are closed, otherwise fds > 2 are closed
Example:
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

◆ dirname() [1/2]

string Qore::dirname ( string  path)

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

Code Flags:
CONSTANT
Parameters
paththe 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()

◆ dirname() [2/2]

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

◆ errno()

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

◆ exec()

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
commandthe 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");

◆ exit()

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
rcthe return code for the process (0 = no error; success)
Example:
exit(0);
See also
abort()

◆ fork()

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-FORKCannot 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()

◆ get_netif_list()

list<hash<NetIfInfo> > Qore::get_netif_list ( )

returns a list of network interfaces

Platform Availability:
Qore::Option::HAVE_GET_NETIF_LIST
Restrictions:
Qore::PO_NO_EXTERNAL_INFO
Example:
list<hash<NetIfInfo>> l = get_netif_list();
results for example into:
list: (8 elements)
[0]=hash: (5 members)
interface : "lo"
address : "00:00:00:00:00:00"
address_desc : "mac<00:00:00:00:00:00>"
family : 17
familystr : "mac"
[1]=hash: (5 members)
interface : "eth0"
address : "44:8a:5b:ba:13:50"
address_desc : "mac<44:8a:5b:ba:13:50>"
family : 17
familystr : "mac"
[2]=hash: (5 members)
interface : "lo"
address : "127.0.0.1"
address_desc : "ipv4(127.0.0.1)"
family : 2
familystr : "ipv4"
[3]=hash: (5 members)
interface : "eth0"
address : "192.168.20.4"
address_desc : "ipv4(192.168.20.4)"
family : 2
familystr : "ipv4"
[4]=hash: (5 members)
interface : "lo"
address : "::1"
address_desc : "ipv6[::1]"
family : 10
familystr : "ipv6"
[5]=hash: (5 members)
interface : "eth0"
address : "fe80::213:3bff:fe0f:d5e1"
address_desc : "ipv6[fe80::213:3bff:fe0f:d5e1]"
family : 10
familystr : "ipv6"
Returns
returns a list of network interfaces available on the local machine

◆ getaddrinfo()

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
nodeThe host name or node name to look up
serviceThe service name to look up to a port number
familyThe 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
flagssee 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-ERRORnodename nor servname provided, or not known

◆ getegid()

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();

◆ geteuid()

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();

◆ getgid()

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();

◆ getgroups()

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

◆ gethostbyaddr() [1/2]

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

Returns the official hostname corresponding to the network address 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
addrthe address to look up
typethe 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-ERRORinvalid 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

◆ gethostbyaddr() [2/2]

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

◆ gethostbyaddr_long() [1/2]

*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
addrthe address to look up
typethe 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-ERRORinvalid 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

◆ gethostbyaddr_long() [2/2]

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

◆ gethostbyname() [1/2]

*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
namethe 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

◆ gethostbyname() [2/2]

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

◆ gethostbyname_long() [1/2]

*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
namethe 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

◆ gethostbyname_long() [2/2]

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

◆ gethostname()

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();

◆ getpid()

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();

◆ getppid()

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;

◆ getuid()

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();

◆ kill() [1/2]

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
pidthe 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.
sigthe 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());

◆ kill() [2/2]

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

◆ rand()

int Qore::rand ( )

Returns a random non-negative 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 non-negative 64-bit integer number
Code Flags:
CONSTANT
Example:
int num = rand();
See also
srand() for a function to seed the random number generator
Since
Qore 0.8.13 the random number generator is seeded randomly when the Qore library is initialized

◆ setegid()

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
gidthe 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());

◆ seteuid()

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
uidthe 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());

◆ setgid()

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
gidthe 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());

◆ setgroups()

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:
Parameters
gidsa list of supplementary group IDs for the current process
Since
Qore 0.8.11.1

◆ setsid()

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());

◆ setuid()

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
uidthe 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());

◆ sleep() [1/2]

int Qore::sleep ( softint  seconds)

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

Restrictions:
Qore::PO_NO_PROCESS_CONTROL
Parameters
secondsThe 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

◆ sleep() [2/2]

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

◆ srand() [1/2]

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
seedthe seed for the random number generator (only the least-significant 32-bits are used)
Example:
See also
rand() for a function that returns a random number related to the seed given here
Since
Qore 0.8.13 the random number generator is seeded randomly when the Qore library is initialized

◆ srand() [2/2]

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

◆ strerror() [1/2]

string Qore::strerror ( softint  err)

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

Code Flags:
CONSTANT
Parameters
errthe 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()));

◆ strerror() [2/2]

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

◆ system() [1/2]

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
commandthe command to execute with system() (3)
Returns
the exit code of the process executed
Example:
int rc = system("ls -l");
See also

◆ system() [2/2]

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

◆ usleep() [1/3]

int Qore::usleep ( softint  usecs)

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

Restrictions:
Qore::PO_NO_PROCESS_CONTROL
Parameters
usecsThe 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)

◆ usleep() [2/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
dA 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)

◆ usleep() [3/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