Ref/posix-Phpdoc专题
The section about Process Control Functions maybe of interest for you.
posix_access
Determine accessibility of a file
说明
bool <span
class="methodname">posix_access ( <span
class="methodparam">string $filename
[, int
$flags = 0 ] )
posix_access checks the user's permission of a file.
参数
filename
The name of the file to be tested.
flags
A mask consisting of one or more of POSIX_F_OK, POSIX_R_OK,
POSIX_W_OK and POSIX_X_OK.
POSIX_R_OK, POSIX_W_OK and POSIX_X_OK request checking
whether the file exists and has read, write and execute permissions,
respectively. POSIX_F_OK just requests checking for the existence
of the file.
返回值
成功时返回 true, 或者在失败时返回 false。
范例
示例 #1 posix_access example
This example will check if the $file is readable and writable, otherwise will print an error message.
<?php
$file = 'some_file';
if (posix_access($file, POSIX_R_OK | POSIX_W_OK)) {
echo 'The file is readable and writable!';
} else {
$error = posix_get_last_error();
echo "Error $error: " . posix_strerror($error);
}
?>
注释
参见
- posix_get_last_error
- posix_strerror
posix_ctermid
Get path name of controlling terminal
说明
string<span class="type">false <span class="methodname">posix_ctermid ( <span class="methodparam">void )
Generates a string which is the pathname for the current controlling terminal for the process. On error this will set errno, which can be checked using <span class="function">posix_get_last_error
返回值
Upon successful completion, returns string of
the pathname to the current controlling terminal. Otherwise false
is returned and errno is set, which can be checked with <span
class="function">posix_get_last_error.
范例
示例 #1 posix_ctermid example
This example will display the path to the current TTY.
<?php
echo "I am running from ".posix_ctermid();
?>
参见
- posix_ttyname
- posix_get_last_error
posix_errno
别名 posix_get_last_error
说明
此函数是该函数的别名: <span class="function">posix_get_last_error.
posix_get_last_error
Retrieve the error number set by the last posix function that failed
说明
int <span class="methodname">posix_get_last_error ( <span class="methodparam">void )
Retrieve the error number set by the last posix function that failed. The system error message associated with the errno may be checked with posix_strerror.
返回值
Returns the errno (error number) set by the last posix function that failed. If no errors exist, 0 is returned.
范例
示例 #1 posix_get_last_error example
This example attempt to kill a bogus process id, which will set the last error. We will then print out the last errno.
<?php
posix_kill(999459,SIGKILL);
echo 'Your error returned was '.posix_get_last_error(); //Your error was ___
?>
参见
- posix_strerror
posix_getcwd
Pathname of current directory
说明
string<span class="type">false <span class="methodname">posix_getcwd ( <span class="methodparam">void )
Gets the absolute pathname of the script's current working directory. On error, it sets errno which can be checked using <span class="function">posix_get_last_error
返回值
Returns a string of the absolute pathname on
success. On error, returns false and sets errno which can be
checked with posix_get_last_error.
范例
示例 #1 posix_getcwd example
This example will return the absolute path of the current working directory of the script.
<?php
echo 'My current working directory is '.posix_getcwd();
?>
注释
Note:
This function can fail on
- Read or Search permission was denied
- Pathname no longer exists
posix_getegid
Return the effective group ID of the current process
说明
int <span class="methodname">posix_getegid ( <span class="methodparam">void )
Return the numeric effective group ID of the current process.
返回值
Returns an int of the effective group ID.
范例
示例 #1 posix_getegid example
This example will print out the effective group id, once it is changed with posix_setegid.
<?php
echo 'My real group id is '.posix_getgid(); //20
posix_setegid(40);
echo 'My real group id is '.posix_getgid(); //20
echo 'My effective group id is '.posix_getegid(); //40
?>
注释
posix_getegid is different than <span class="function">posix_getgid because effective group ID can be changed by a calling process using <span class="function">posix_setegid.
参见
- posix_getgrgid
- posix_getgid
- posix_setgid
posix_geteuid
Return the effective user ID of the current process
说明
int <span class="methodname">posix_geteuid ( <span class="methodparam">void )
Return the numeric effective user ID of the current process. See also posix_getpwuid for information on how to convert this into a useable username.
返回值
Returns the user id, as an int
范例
示例 #1 posix_geteuid example
This example will show the current user id then set the effective user id to a separate id using posix_seteuid, then show the difference between the real id and the effective id.
<?php
echo posix_getuid()."\n"; //10001
echo posix_geteuid()."\n"; //10001
posix_seteuid(10000);
echo posix_getuid()."\n"; //10001
echo posix_geteuid()."\n"; //10000
?>
参见
- posix_getpwuid
- posix_getuid
- posix_setuid
- POSIX man page GETEUID(2)
posix_getgid
Return the real group ID of the current process
说明
int <span class="methodname">posix_getgid ( <span class="methodparam">void )
Return the numeric real group ID of the current process.
返回值
Returns the real group id, as an int.
范例
示例 #1 posix_getgid example
This example will print out the real group id, even once the effective group id has been changed.
<?php
echo 'My real group id is '.posix_getgid(); //20
posix_setegid(40);
echo 'My real group id is '.posix_getgid(); //20
echo 'My effective group id is '.posix_getegid(); //40
?>
参见
- posix_getgrgid
- posix_getegid
- posix_setgid
- POSIX man page GETGID(2)
posix_getgrgid
Return info about a group by group id
说明
array<span
class="type">false <span
class="methodname">posix_getgrgid ( <span
class="methodparam">int $group_id )
Gets information about a group provided its id.
参数
group_id
The group id.
返回值
The array elements returned are:
| Element | Description |
|---|---|
| name | The name element contains the name of the group. This is a short, usually less than 16 character "handle" of the group, not the real, full name. |
| passwd | The passwd element contains the group's password in an encrypted format. Often, for example on a system employing "shadow" passwords, an asterisk is returned instead. |
| gid | Group ID, should be the same as the group_id parameter used when calling the function, and hence redundant. |
| members | This consists of an array of string's for all the members in the group. |
The function returns false on failure.
范例
示例 #1 Example use of <span class="function">posix_getgrgid
<?php
$groupid = posix_getegid();
$groupinfo = posix_getgrgid($groupid);
print_r($groupinfo);
?>
以上例程的输出类似于:
Array
(
[name] => toons
[passwd] => x
[members] => Array
(
[0] => tom
[1] => jerry
)
[gid] => 42
)
参见
- posix_getegid
- posix_getgrnam
- filegroup
- stat
- POSIX man page GETGRNAM(3)
posix_getgrnam
Return info about a group by name
说明
array<span
class="type">false <span
class="methodname">posix_getgrnam ( <span
class="methodparam">string $name )
Gets information about a group provided its name.
参数
name
The name of the group
返回值
Returns an array on success, 或者在失败时返回
false. The array elements returned are:
| Element | Description |
|---|---|
| name | The name element contains the name of the group. This is a short, usually less than 16 character "handle" of the group, not the real, full name. This should be the same as the name parameter used when calling the function, and hence redundant. |
| passwd | The passwd element contains the group's password in an encrypted format. Often, for example on a system employing "shadow" passwords, an asterisk is returned instead. |
| gid | Group ID of the group in numeric form. |
| members | This consists of an array of string's for all the members in the group. |
范例
示例 #1 Example use of <span class="function">posix_getgrnam
<?php
$groupinfo = posix_getgrnam("toons");
print_r($groupinfo);
?>
以上例程的输出类似于:
Array
(
[name] => toons
[passwd] => x
[members] => Array
(
[0] => tom
[1] => jerry
)
[gid] => 42
)
参见
- posix_getegid
- posix_getgrgid
- filegroup
- stat
- POSIX man page GETGRNAM(3)
posix_getgroups
Return the group set of the current process
说明
array<span class="type">false <span class="methodname">posix_getgroups ( <span class="methodparam">void )
Gets the group set of the current process.
返回值
Returns an array of integers containing the numeric group ids of the
group set of the current process, 或者在失败时返回 false.
范例
示例 #1 Example use of <span class="function">posix_getgroups
<?php
$groups = posix_getgroups();
print_r($groups);
?>
以上例程的输出类似于:
Array
(
[0] => 4
[1] => 20
[2] => 24
[3] => 25
[4] => 29
[5] => 30
[6] => 33
[7] => 44
[8] => 46
[9] => 104
[10] => 109
[11] => 110
[12] => 1000
)
参见
- posix_getgrgid
posix_getlogin
Return login name
说明
string<span class="type">false <span class="methodname">posix_getlogin ( <span class="methodparam">void )
Returns the login name of the user owning the current process.
返回值
Returns the login name of the user, as a <span
class="type">string, 或者在失败时返回 false.
范例
示例 #1 Example use of <span class="function">posix_getlogin
<?php
echo posix_getlogin(); //apache
?>
参见
- posix_getpwnam
- POSIX man page GETLOGIN(3)
posix_getpgid
Get process group id for job control
说明
int<span
class="type">false <span
class="methodname">posix_getpgid ( <span
class="methodparam">int $process_id )
Returns the process group identifier of the process process_id
或者在失败时返回 false.
参数
process_id
The process id.
返回值
Returns the identifier, as an int.
范例
示例 #1 Example use of posix_getpgid
<?php
$pid = posix_getppid();
echo posix_getpgid($pid); //35
?>
注释
Note:
This is a not POSIX function, but is common on BSD and System V systems. If the system does not support this function, then it will not be included at compile time. This may be checked with <span class="function">function_exists.
参见
- posix_getppid
- man page SETPGID(2)
posix_getpgrp
Return the current process group identifier
说明
int <span class="methodname">posix_getpgrp ( <span class="methodparam">void )
Return the process group identifier of the current process.
返回值
Returns the identifier, as an int.
参见
- POSIX.1 and the getpgrp(2) manual page on the POSIX system for more information on process groups.
posix_getpid
返回当前进程 id
说明
int <span class="methodname">posix_getpid ( <span class="methodparam">void )
Return the process identifier of the current process. 返回当前进程的 id
返回值
返回进程 id 号,是整型(integer)。
范例
示例 #1 posix_getpid 的使用例子
<?php
echo posix_getpid(); //8805
?>
参见
- posix_kill
- POSIX man page GETPID(2)
posix_getppid
Return the parent process identifier
说明
int <span class="methodname">posix_getppid ( <span class="methodparam">void )
Return the process identifier of the parent process of the current process.
返回值
Returns the identifier, as an int.
范例
示例 #1 Example use of posix_getppid
<?php
echo posix_getppid(); //8259
?>
posix_getpwnam
Return info about a user by username
说明
array<span
class="type">false <span
class="methodname">posix_getpwnam ( <span
class="methodparam">string $username
)
Returns an array of information about the given user.
参数
username
An alphanumeric username.
返回值
On success an array with the following elements is returned, else
false is returned:
| Element | Description |
|---|---|
| name | The name element contains the username of the user. This is a short, usually less than 16 character "handle" of the user, not the real, full name. This should be the same as the username parameter used when calling the function, and hence redundant. |
| passwd | The passwd element contains the user's password in an encrypted format. Often, for example on a system employing "shadow" passwords, an asterisk is returned instead. |
| uid | User ID of the user in numeric form. |
| gid | The group ID of the user. Use the function posix_getgrgid to resolve the group name and a list of its members. |
| gecos | GECOS is an obsolete term that refers to the finger information field on a Honeywell batch processing system. The field, however, lives on, and its contents have been formalized by POSIX. The field contains a comma separated list containing the user's full name, office phone, office number, and home phone number. On most systems, only the user's full name is available. |
| dir | This element contains the absolute path to the home directory of the user. |
| shell | The shell element contains the absolute path to the executable of the user's default shell. |
范例
示例 #1 Example use of <span class="function">posix_getpwnam
<?php
$userinfo = posix_getpwnam("tom");
print_r($userinfo);
?>
以上例程的输出类似于:
Array
(
[name] => tom
[passwd] => x
[uid] => 10000
[gid] => 42
[gecos] => "tom,,,"
[dir] => "/home/tom"
[shell] => "/bin/bash"
)
参见
- posix_getpwuid
- POSIX man page GETPWNAM(3)
posix_getpwuid
Return info about a user by user id
说明
array<span
class="type">false <span
class="methodname">posix_getpwuid ( <span
class="methodparam">int $user_id )
Returns an array of information about the user referenced by the given user ID.
参数
user_id
The user identifier.
返回值
Returns an associative array with the following elements:
| Element | Description |
|---|---|
| name | The name element contains the username of the user. This is a short, usually less than 16 character "handle" of the user, not the real, full name. |
| passwd | The passwd element contains the user's password in an encrypted format. Often, for example on a system employing "shadow" passwords, an asterisk is returned instead. |
| uid | User ID, should be the same as the user_id parameter used when calling the function, and hence redundant. |
| gid | The group ID of the user. Use the function posix_getgrgid to resolve the group name and a list of its members. |
| gecos | GECOS is an obsolete term that refers to the finger information field on a Honeywell batch processing system. The field, however, lives on, and its contents have been formalized by POSIX. The field contains a comma separated list containing the user's full name, office phone, office number, and home phone number. On most systems, only the user's full name is available. |
| dir | This element contains the absolute path to the home directory of the user. |
| shell | The shell element contains the absolute path to the executable of the user's default shell. |
The function returns false on failure.
范例
示例 #1 Example use of <span class="function">posix_getpwuid
<?php
$userinfo = posix_getpwuid(10000);
print_r($userinfo);
?>
以上例程的输出类似于:
Array
(
[name] => tom
[passwd] => x
[uid] => 10000
[gid] => 42
[gecos] => "tom,,,"
[dir] => "/home/tom"
[shell] => "/bin/bash"
)
参见
- posix_getpwnam
- POSIX man page GETPWNAM(3)
posix_getrlimit
Return info about system resource limits
说明
array<span class="type">false <span class="methodname">posix_getrlimit ( <span class="methodparam">void )
posix_getrlimit returns an <span class="type">array of information about the current resource's soft and hard limits.
Each resource has an associated soft and hard limit. The soft limit is the value that the kernel enforces for the corresponding resource. The hard limit acts as a ceiling for the soft limit. An unprivileged process may only set its soft limit to a value from 0 to the hard limit, and irreversibly lower its hard limit.
返回值
Returns an associative array of elements for each limit that is defined. Each limit has a soft and a hard limit.
| Limit name | Limit description |
|---|---|
| core | The maximum size of the core file. When 0, not core files are created. When core files are larger than this size, they will be truncated at this size. |
| totalmem | The maximum size of the memory of the process, in bytes. |
| virtualmem | The maximum size of the virtual memory for the process, in bytes. |
| data | The maximum size of the data segment for the process, in bytes. |
| stack | The maximum size of the process stack, in bytes. |
| rss | The maximum number of virtual pages resident in RAM |
| maxproc | The maximum number of processes that can be created for the real user ID of the calling process. |
| memlock | The maximum number of bytes of memory that may be locked into RAM. |
| cpu | The amount of time the process is allowed to use the CPU. |
| filesize | The maximum size of the data segment for the process, in bytes. |
| openfiles | One more than the maximum number of open file descriptors. |
The function returns false on failure.
范例
示例 #1 Example use of <span class="function">posix_getrlimit
<?php
$limits = posix_getrlimit();
print_r($limits);
?>
以上例程的输出类似于:
Array
(
[soft core] => 0
[hard core] => unlimited
[soft data] => unlimited
[hard data] => unlimited
[soft stack] => 8388608
[hard stack] => unlimited
[soft totalmem] => unlimited
[hard totalmem] => unlimited
[soft rss] => unlimited
[hard rss] => unlimited
[soft maxproc] => unlimited
[hard maxproc] => unlimited
[soft memlock] => unlimited
[hard memlock] => unlimited
[soft cpu] => unlimited
[hard cpu] => unlimited
[soft filesize] => unlimited
[hard filesize] => unlimited
[soft openfiles] => 1024
[hard openfiles] => 1024
)
参见
- man page GETRLIMIT(2)
- posix_setrlimit
posix_getsid
Get the current sid of the process
说明
int<span
class="type">false <span
class="methodname">posix_getsid ( <span
class="methodparam">int $process_id )
Return the session id of the process process_id. The session id of a
process is the process group id of the session leader.
参数
process_id
The process identifier. If set to 0, the current process is assumed. If
an invalid process_id is specified, then false is returned and
an error is set which can be checked with <span
class="function">posix_get_last_error.
返回值
Returns the identifier, as an int,
或者在失败时返回 false.
范例
示例 #1 Example use of posix_getsid
<?php
$pid = posix_getpid();
echo posix_getsid($pid); //8805
?>
参见
- posix_getpgid
- posix_setsid
- POSIX man page GETSID(2)
posix_getuid
Return the real user ID of the current process
说明
int <span class="methodname">posix_getuid ( <span class="methodparam">void )
Return the numeric real user ID of the current process.
返回值
Returns the user id, as an int
范例
示例 #1 Example use of posix_getuid
<?php
echo posix_getuid(); //10000
?>
参见
- posix_getpwuid
- POSIX man page GETUID(2)
posix_initgroups
Calculate the group access list
说明
bool <span
class="methodname">posix_initgroups ( <span
class="methodparam">string $username
, int
$group_id )
Calculates the group access list for the user specified in name.
参数
username
The user to calculate the list for.
group_id
Typically the group number from the password file.
返回值
成功时返回 true, 或者在失败时返回 false。
参见
- The Unix manual page for initgroups(3).
posix_isatty
Determine if a file descriptor is an interactive terminal
说明
bool <span
class="methodname">posix_isatty ( <span
class="methodparam"><span
class="type">resourceint
$file_descriptor )
Determines if the file descriptor file_descriptor refers to a valid
terminal type device.
参数
fd
The file descriptor, which is expected to be either a file <span
class="type">resource or an int. An
int will be assumed to be a file descriptor
that can be passed directly to the underlying system call.
In almost all cases, you will want to provide a file <span class="type">resource.
返回值
Returns true if file_descriptor is an open descriptor connected
to a terminal and false otherwise.
参见
- posix_ttyname
- stream_isatty
posix_kill
Send a signal to a process
说明
bool <span
class="methodname">posix_kill ( <span
class="type">int $process_id , <span
class="methodparam">int $signal )
Send the signal signal to the process with the process identifier
process_id.
参数
process_id
The process identifier.
signal
One of the
PCNTL signals constants.
返回值
成功时返回 true, 或者在失败时返回 false。
参见
- The kill(2) manual page of the POSIX system, which contains additional information about negative process identifiers, the special pid 0, the special pid -1, and the signal number 0.
posix_mkfifo
Create a fifo special file (a named pipe)
说明
bool <span
class="methodname">posix_mkfifo ( <span
class="methodparam">string $filename
, int
$permissions )
posix_mkfifo creates a special FIFO file which exists in the file system and acts as a bidirectional communication endpoint for processes.
参数
filename
Path to the FIFO file.
permissions
The second parameter permissions has to be given in octal notation
(e.g. 0644). The permission of the newly created FIFO also depends on
the setting of the current umask. The
permissions of the created file are (mode & ~umask).
返回值
成功时返回 true, 或者在失败时返回 false。
posix_mknod
Create a special or ordinary file (POSIX.1)
说明
bool <span
class="methodname">posix_mknod ( <span
class="type">string $filename , <span
class="methodparam">int $flags [,
int $major<span
class="initializer"> = 0 [, <span
class="methodparam">int $minor<span
class="initializer"> = 0 ]] )
Creates a special or ordinary file.
参数
filename
The file to create
flags
This parameter is constructed by a bitwise OR between file type (one of
the following constants: POSIX_S_IFREG, POSIX_S_IFCHR,
POSIX_S_IFBLK, POSIX_S_IFIFO or POSIX_S_IFSOCK) and
permissions.
major
The major device kernel identifier (required to pass when using
S_IFCHR or S_IFBLK).
minor
The minor device kernel identifier.
返回值
成功时返回 true, 或者在失败时返回 false。
范例
示例 #1 A posix_mknod example
<?php
$file = '/tmp/tmpfile'; // file name
$type = POSIX_S_IFBLK; // file type
$permissions = 0777; // octal
$major = 1;
$minor = 8; // /dev/random
if (!posix_mknod($file, $type | $permissions, $major, $minor)) {
die('Error ' . posix_get_last_error() . ': ' . posix_strerror(posix_get_last_error()));
}
?>
参见
- posix_mkfifo
posix_setegid
Set the effective GID of the current process
说明
bool <span
class="methodname">posix_setegid ( <span
class="methodparam">int $group_id )
Set the effective group ID of the current process. This is a privileged function and needs appropriate privileges (usually root) on the system to be able to perform this function.
参数
group_id
The group id.
返回值
成功时返回 true, 或者在失败时返回 false。
范例
示例 #1 posix_setegid example
This example will print out the effective group id, once changed.
<?php
echo 'My real group id is '.posix_getgid(); //20
posix_setegid(40);
echo 'My real group id is '.posix_getgid(); //20
echo 'My effective group id is '.posix_getegid(); //40
?>
参见
- posix_getgrgid
- posix_getgid
- posix_setgid
posix_seteuid
Set the effective UID of the current process
说明
bool <span
class="methodname">posix_seteuid ( <span
class="methodparam">int $user_id )
Set the effective user ID of the current process. This is a privileged function and needs appropriate privileges (usually root) on the system to be able to perform this function.
参数
user_id
The user id.
返回值
成功时返回 true, 或者在失败时返回 false。
参见
- posix_geteuid
- posix_setuid
- posix_getuid
posix_setgid
Set the GID of the current process
说明
bool <span
class="methodname">posix_setgid ( <span
class="methodparam">int $group_id )
Set the real group ID of the current process. This is a privileged function and needs appropriate privileges (usually root) on the system to be able to perform this function. The appropriate order of function calls is posix_setgid first, <span class="function">posix_setuid last.
Note:
If the caller is a super user, this will also set the effective group id.
参数
group_id
The group id.
返回值
成功时返回 true, 或者在失败时返回 false。
范例
示例 #1 posix_setgid example
This example will print out the effective group id, once it is changed.
<?php
echo 'My real group id is '.posix_getgid(); //20
posix_setgid(40);
echo 'My real group id is '.posix_getgid(); //40
echo 'My effective group id is '.posix_getegid(); //40
?>
参见
- posix_getgrgid
- posix_getgid
posix_setpgid
Set process group id for job control
说明
bool <span
class="methodname">posix_setpgid ( <span
class="methodparam">int $process_id ,
int
$process_group_id )
Let the process process_id join the process group process_group_id.
参数
process_id
The process id.
process_group_id
The process group id.
返回值
成功时返回 true, 或者在失败时返回 false。
参见
- See POSIX.1 and the setsid(2) manual page on the POSIX system for more information on process groups and job control.
posix_setrlimit
Set system resource limits
说明
bool <span
class="methodname">posix_setrlimit ( <span
class="methodparam">int $resource ,
int
$soft_limit , <span
class="type">int $hard_limit )
posix_setrlimit sets the soft and hard limits for a given system resource.
Each resource has an associated soft and hard limit. The soft limit is the value that the kernel enforces for the corresponding resource. The hard limit acts as a ceiling for the soft limit. An unprivileged process may only set its soft limit to a value from 0 to the hard limit, and irreversibly lower its hard limit.
参数
resource
The
resource limit constant
corresponding to the limit that is being set.
soft_limit
The soft limit, in whatever unit the resource limit requires, or
POSIX_RLIMIT_INFINITY.
hard_limit
The hard limit, in whatever unit the resource limit requires, or
POSIX_RLIMIT_INFINITY.
返回值
成功时返回 true, 或者在失败时返回 false。
参见
- man page SETRLIMIT(2)
- posix_getrlimit
posix_setsid
Make the current process a session leader
说明
int <span class="methodname">posix_setsid ( <span class="methodparam">void )
Make the current process a session leader.
返回值
Returns the session id, or -1 on errors.
参见
- The POSIX.1 and the setsid(2) manual page on the POSIX system for more information on process groups and job control.
posix_setuid
Set the UID of the current process
说明
bool <span
class="methodname">posix_setuid ( <span
class="methodparam">int $user_id )
Set the real user ID of the current process. This is a privileged function that needs appropriate privileges (usually root) on the system to be able to perform this function.
参数
user_id
The user id.
返回值
成功时返回 true, 或者在失败时返回 false。
范例
示例 #1 posix_setuid example
This example will show the current user id and then set it to a different value.
<?php
echo posix_getuid()."\n"; //10001
echo posix_geteuid()."\n"; //10001
posix_setuid(10000);
echo posix_getuid()."\n"; //10000
echo posix_geteuid()."\n"; //10000
?>
参见
- posix_setgid
- posix_seteuid
- posix_getuid
- posix_geteuid
posix_strerror
Retrieve the system error message associated with the given errno
说明
string <span
class="methodname">posix_strerror ( <span
class="methodparam">int $error_code )
Returns the POSIX system error message associated with the given
error_code. You may get the error_code parameter by calling <span
class="function">posix_get_last_error.
参数
error_code
A POSIX error number, returned by <span
class="function">posix_get_last_error. If set to 0, then the
string "Success" is returned.
返回值
Returns the error message, as a string.
范例
示例 #1 posix_strerror example
This example will attempt to kill a process which does not exist, then will print out the corresponding error message.
<?php
posix_kill(50,SIGKILL);
echo posix_strerror(posix_get_last_error())."\n";
?>
以上例程的输出类似于:
No such process
参见
- posix_get_last_error
posix_times
Get process times
说明
array<span class="type">false <span class="methodname">posix_times ( <span class="methodparam">void )
Gets information about the current CPU usage.
返回值
Returns a hash of strings with information about the current process CPU usage. The indices of the hash are:
- ticks - the number of clock ticks that have elapsed since reboot.
- utime - user time used by the current process.
- stime - system time used by the current process.
- cutime - user time used by current process and children.
- cstime - system time used by current process and children.
The function returns false on failure.
注释
Warning
This function isn't reliable to use, it may return negative values for high times.
范例
示例 #1 Example use of posix_times
<?php
$times = posix_times();
print_r($times);
?>
以上例程的输出类似于:
Array
(
[ticks] => 25814410
[utime] => 1
[stime] => 1
[cutime] => 0
[cstime] => 0
)
posix_ttyname
Determine terminal device name
说明
string<span
class="type">false <span
class="methodname">posix_ttyname ( <span
class="methodparam"><span
class="type">resourceint
$file_descriptor )
Returns a string for the absolute path to the
current terminal device that is open on the file descriptor
file_descriptor.
参数
fd
The file descriptor, which is expected to be either a file <span
class="type">resource or an int. An
int will be assumed to be a file descriptor
that can be passed directly to the underlying system call.
In almost all cases, you will want to provide a file <span class="type">resource.
返回值
On success, returns a string of the absolute
path of the file_descriptor. On failure, returns false
posix_uname
Get system name
说明
array<span class="type">false <span class="methodname">posix_uname ( <span class="methodparam">void )
Gets information about the system.
Posix requires that assumptions must not be made about the format of the values, e.g. the assumption that a release may contain three digits or anything else returned by this function.
返回值
Returns a hash of strings with information about the system. The indices of the hash are
- sysname - operating system name (e.g. Linux)
- nodename - system name (e.g. valiant)
- release - operating system release (e.g. 2.2.10)
- version - operating system version (e.g. #4 Tue Jul 20 17:01:36 MEST 1999)
- machine - system architecture (e.g. i586)
- domainname - DNS domainname (e.g. example.com)
domainname is a GNU extension and not part of POSIX.1, so this field is only available on GNU systems or when using the GNU libc.
The function returns false on failure.
范例
示例 #1 Example use of posix_uname
<?php
$uname=posix_uname();
print_r($uname);
?>
以上例程的输出类似于:
Array
(
[sysname] => Linux
[nodename] => funbox
[release] => 2.6.20-15-server
[version] => #2 SMP Sun Apr 15 07:41:34 UTC 2007
[machine] => i686
)
目录
- posix_access — Determine accessibility of a file
- posix_ctermid — Get path name of controlling terminal
- posix_errno — 别名 posix_get_last_error
- posix_get_last_error — Retrieve the error number set by the last posix function that failed
- posix_getcwd — Pathname of current directory
- posix_getegid — Return the effective group ID of the current process
- posix_geteuid — Return the effective user ID of the current process
- posix_getgid — Return the real group ID of the current process
- posix_getgrgid — Return info about a group by group id
- posix_getgrnam — Return info about a group by name
- posix_getgroups — Return the group set of the current process
- posix_getlogin — Return login name
- posix_getpgid — Get process group id for job control
- posix_getpgrp — Return the current process group identifier
- posix_getpid — 返回当前进程 id
- posix_getppid — Return the parent process identifier
- posix_getpwnam — Return info about a user by username
- posix_getpwuid — Return info about a user by user id
- posix_getrlimit — Return info about system resource limits
- posix_getsid — Get the current sid of the process
- posix_getuid — Return the real user ID of the current process
- posix_initgroups — Calculate the group access list
- posix_isatty — Determine if a file descriptor is an interactive terminal
- posix_kill — Send a signal to a process
- posix_mkfifo — Create a fifo special file (a named pipe)
- posix_mknod — Create a special or ordinary file (POSIX.1)
- posix_setegid — Set the effective GID of the current process
- posix_seteuid — Set the effective UID of the current process
- posix_setgid — Set the GID of the current process
- posix_setpgid — Set process group id for job control
- posix_setrlimit — Set system resource limits
- posix_setsid — Make the current process a session leader
- posix_setuid — Set the UID of the current process
- posix_strerror — Retrieve the system error message associated with the given errno
- posix_times — Get process times
- posix_ttyname — Determine terminal device name
- posix_uname — Get system name