Aborts the current program (this function does not return).
abort();
Not available with PO_NO_PROCESS_CONTROL
This function does not throw any exceptions.
This function does not throw any exceptions.
Returns the error code of the last error that occurred in the current thread. See strerror() for a function that gives the string description for the error number returned by this function.
$str = strerror(errno());
Table 3.133. Arguments and Return Values for errno()
Argument Type | Return Type | Description |
|---|---|---|
n/a | The error code of the most recent error in the current thread is returned. |
This function does not throw any exceptions.
Replaces the current process image with another. This function does not return.
exec("/bin/ls -l");
Not available with PO_NO_PROCESS_CONTROL or PO_NO_EXTERNAL_PROCESS
Table 3.134. Arguments and Return Values for exec()
Argument Type | Return Type | Description |
|---|---|---|
n/a | The process and any arguments to the process to execute. This function does not return. |
This function does not throw any exceptions.
Exits the program with the return code passed (this function does not return).
exit(2);
Not available with PO_NO_PROCESS_CONTROL
Table 3.135. Arguments and Return Values for exit()
Argument Type | Return Type | Description |
|---|---|---|
n/a | Exits the program with the return code set to the value of the argument passed converted to an integer if necessary. |
This function does not throw any exceptions.
Creates a copy of the current process with a new PID. Returns 0 in the child process, the child's PID in the parent process. This function will throw an exception if more than one thread is running.
$pid = fork();
Not available with PO_NO_PROCESS_CONTROL
Table 3.136. Arguments and Return Values for fork()
Argument Type | Return Type | Description |
|---|---|---|
n/a | The child's PID is returned in the parent process, 0 is returned in the child's process. If -1 is returned, then no child was started and the error number can be retrieved with the errno() function. |
Table 3.137. Exceptions Thrown by fork()
err | desc |
|---|---|
| Cannot fork if more than one thread is running. |
| This exception is thrown when the function is not available on the runtime platform; for maximum portability, check the constant |
Returns a list of address information hashes for the given node name or string address. If no lookup can be performed then an exception is thrown.
list getaddrinfo(*string $node, *softstring $service, softint $family = AF_UNSPEC, softint $flags = 0) (CONST)
my list $l = getaddrinfo("localhost");
Not available with PO_NO_EXTERNAL_INFO
Table 3.138. Arguments for getaddrinfo()
Argument | Description |
|---|---|
| The host name or node name to look up. Either |
| The service name to look up to a port number. Either |
| The address family for the lookup, must be one of |
|
Table 3.139. Return Value for getaddrinfo()
Return Type | Description |
|---|---|
Returns a list of address information hashes for the given node name or string address. If no lookup can be performed then an exception is thrown. |
Table 3.140. Exceptions Thrown by getaddrinfo()
err | desc |
|---|---|
| nodename nor servname provided, or not known. |
Table 3.141. Address Information Hash
Key | Type | Description |
|---|---|---|
| A valid address of the host, for example: | |
| A descriptive string of the address containing the address family, for example: | |
| The network address family; see Network Address Family Constants. | |
| A descriptive string for the network address family, for example: | |
| The length of the internal network address data structure (not normally needed in Qore but provided anyway). |
Returns the effective group ID of the current process.
$egid = getegid();
Not available with PO_NO_EXTERNAL_INFO
Table 3.142. Arguments and Return Values for getegid()
Argument Type | Return Type | Description |
|---|---|---|
n/a | Returns the effective group ID of the current process. |
Table 3.143. Exceptions Thrown by getegid()
err | desc |
|---|---|
| This exception is thrown when the function is not available on the runtime platform; for maximum portability, check the constant |
Returns the effective user ID of the current process.
Not available with PO_NO_EXTERNAL_INFO
Table 3.144. Arguments and Return Values for geteuid()
Argument Type | Return Type | Description |
|---|---|---|
n/a | Returns the effective user ID of the current process. |
Table 3.145. Exceptions Thrown by geteuid()
err | desc |
|---|---|
| This exception is thrown when the function is not available on the runtime platform; for maximum portability, check the constant |
Returns the real group ID of the current process.
my int $gid = getgid();
Not available with PO_NO_EXTERNAL_INFO
Table 3.146. Arguments and Return Values for getgid()
Argument Type | Return Type | Description |
|---|---|---|
n/a | Returns the real group ID of the current process. |
Table 3.147. Exceptions Thrown by geteuid()
err | desc |
|---|---|
| This exception is thrown when the function is not available on the runtime platform; for maximum portability, check the constant |
Returns the official hostname corresponding to the network addressed passed as an argument. If the second argument giving the address type is not passed, then AF_INET (IPv4) is assumed. See Network Address Type Constants for valid values for the second argument. If the address family is invalid or the address string is not a valid address for the given family an exception will be thrown.
For a version of this function that returns all host information, including all hostname aliases and all addresses, see gethostbyaddr_long().
*string gethostbyaddr(string $addr, softint $type = AF_INET) (CONST)
my *string $hostname = gethostbyaddr("192.168.0.33");
Not available with PO_NO_EXTERNAL_INFO
Table 3.149. Exceptions thrown by gethostbyaddr()
err | desc |
|---|---|
| invalid address or invalid address family passed as arguments |
Returns a hash representing all host and address information corresponding to the network addressed passed as an argument. See Host Information Hash for a description of the return value.
If the second argument giving the address type is not passed, then AF_INET (IPv4) is assumed. See Network Address Type Constants for valid values for the second argument. If the address family is invalid or the address string is not a valid address for the given family an exception will be thrown.
For a version of this function that returns just the official hostname corresponding to the address, see gethostbyaddr().
*hash gethostbyaddr_long(string $addr, softint $type = AF_INET) (CONST)
my *hash $hash = gethostbyaddr_long("192.168.0.33");
Not available with PO_NO_EXTERNAL_INFO
Table 3.151. Host Information Hash
Key | Type | Value |
|---|---|---|
| The official fully-qualified name of the host | |
| Any hostname aliases for the host | |
| The type of network address (either "ipv4" or "ipv6") | |
| One of the Network Address Type Constants (either | |
| The length of the addresses in bytes when represented in binary form. | |
| All addresses corresponding to the host; the list should have at least 1 element |
Table 3.152. Exceptions thrown by gethostbyaddr_long()
err | desc |
|---|---|
| invalid address or invalid address family passed as arguments |
Returns the first address corresponding to the hostname passed as an argument.
For a version of this function that returns all host information, including all hostname aliases and all addresses, see gethostbyname_long().
*string gethostbyname(string $name) (CONST)
my *string $addr = gethostbyname("host1");
Not available with PO_NO_EXTERNAL_INFO
This function does not throw any exceptions.
Returns a hash representing all host and address information corresponding to the hostname passed as an argument. See Host Information Hash for a description of the return value.
For a version of this function that returns just the first network address corresponding to the hostname, see gethostbyname().
*hash gethostbyname_long(string $name) (CONST)
my *hash $hash = gethostbyname_long("host1");
Not available with PO_NO_EXTERNAL_INFO
This function does not throw any exceptions.
Returns the hostname of the system.
$host = gethostname();
Not available with PO_NO_EXTERNAL_INFO
Table 3.155. Arguments and Return Values for gethostname()
Argument Type | Return Type | Description |
|---|---|---|
n/a | Returns the hostname of the system. |
This function does not throw any exceptions.
Returns the PID (process ID) of the current process.
$pid = getpid();
Not available with PO_NO_EXTERNAL_INFO
Table 3.156. Arguments and Return Values for getpid()
Argument Type | Return Type | Description |
|---|---|---|
n/a | Returns the PID (process ID) of the current process. |
This function does not throw any exceptions.
Returns the PID (process ID) of the parent process of the current process.
$ppid = getppid();
Not available with PO_NO_EXTERNAL_INFO
Table 3.157. Arguments and Return Values for getppid()
Argument Type | Return Type | Description |
|---|---|---|
n/a | Returns the PID (process ID) of the parent of the current process. |
Table 3.158. Exceptions Thrown by getppid()
err | desc |
|---|---|
| This exception is thrown when the function is not available on the runtime platform; for maximum portability, check the constant |
Returns the real user ID of the current process.
$uid = getuid();
Not available with PO_NO_EXTERNAL_INFO
Table 3.159. Arguments and Return Values for getuid()
Argument Type | Return Type | Description |
|---|---|---|
n/a | Returns the real user ID of the current process. |
Table 3.160. Exceptions Thrown by getuid()
err | desc |
|---|---|
| This exception is thrown when the function is not available on the runtime platform; for maximum portability, check the constant |
Table 3.163. Exceptions Thrown by kill()
err | desc |
|---|---|
| This exception is thrown when the function is not available on the runtime platform; for maximum portability, check the constant |
Changes the process effective group ID according to the argument passed. Returns 0 for success, non-zero for errors (the error code can be retrieved with errno()).
setegid($egid);
Not available with PO_NO_PROCESS_CONTROL
Table 3.165. Exceptions thrown by setegid()
err | desc |
|---|---|
| missing EGID argument to function |
| This exception is thrown when the function is not available; for maximum portability, check the constant |
Changes the process effective user ID according to the argument passed. Returns 0 for success, non-zero for errors (the error code can be retrieved with errno()).
seteuid($euid);
Not available with PO_NO_PROCESS_CONTROL
Table 3.167. Exceptions thrown by seteuid()
|
err |
desc |
|---|---|
|
|
missing EUID argument to function |
| This exception is thrown when the function is not available; for maximum portability, check the constant |
Changes the process group ID according to the argument passed. Returns 0 for success, non-zero for errors (the error code can be retrieved with errno())
setgid($gid);
Not available with PO_NO_PROCESS_CONTROL
Table 3.169. Exceptions Thrown by setgid()
err | desc |
|---|---|
| This exception is thrown when the function is not available on the runtime platform; for maximum portability, check the constant |
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.
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.
my int $rc = setsid();
Not available with PO_NO_PROCESS_CONTROL
Table 3.171. Exceptions Thrown by setsid()
err | desc |
|---|---|
| This exception is thrown when the function is not available on the runtime platform; for maximum portability, check the constant |
Changes the process user ID according to the argument passed. Returns 0 for success, non-zero for errors (the error code can be retrieved with errno())
setuid($uid);
Not available with PO_NO_PROCESS_CONTROL
Table 3.173. Exceptions Thrown by setuid()
err | desc |
|---|---|
| This exception is thrown when the function is not available on the runtime platform; for maximum portability, check the constant |
Causes the current thread to sleep for a certain number of seconds. Note that as with all Qore functions and methods accepting a timeout value, relative date/time values can be given instead of integers to make the source more readable (ie 5s), however as this function only supports a resolution of 1 second, milliseconds are ignored if passed to this function. See usleep() for a similar function supporting microsecond resolution.
sleep(5s); # sleeps for 5 seconds
Not available with PO_NO_PROCESS_CONTROL
Table 3.174. Arguments and Return Values for sleep()
Argument Type | Return Type | Description |
|---|---|---|
Causes the current thread to sleep for a number of seconds equal to the argument passed. Returns 0 for success. An integer argument is interpreted as a number of seconds to sleep, relative date/time values are interpreted literally. |
This function does not throw any exceptions.
This function does not throw any exceptions.
Executes an external program and returns the exit code of the process.
$rc = system("ls -l");
Not available with PO_NO_EXTERNAL_PROCESS
Table 3.177. Exceptions Thrown by system()
err | desc |
|---|---|
| This exception is thrown when the function is not available on the runtime platform; for maximum portability, check the constant |
Causes the current thread to sleep for a certain number of microseconds (1/1000000 second). Note that as with all Qore functions and methods accepting a timeout value, relative date/time values can be given instead of integers to make the source more readable (ie 1250us). See sleep() for a similar function supporting second resolution.
usleep(1250us); # sleeps for 1250 microseconds (1.25 milliseconds)
usleep(500); # sleeps for 500 microseconds (0.5 milliseconds)
Not available with PO_NO_PROCESS_CONTROL
Table 3.178. Arguments and Return Values for usleep()
Argument Type | Return Type | Description |
|---|---|---|
| Causes the current thread to sleep for the given number of microseconds (1/1000000 second). Returns 0 for success. | |
| Causes the current thread to sleep for the given period of time with a resolution of microseconds (1/1000000 second). Returns 0 for success. |
This function does not throw any exceptions.