posix_getgrnam Syntax array posix_getgrnamstring name; Description The posix_getgrnam function returns an associative array with information about the group defined in name.. Associa
Trang 1bool posix_getcwd(string pathname, int mode);
Description
The posix_mkfifo() function creates a named pipe file specified by pathname with
the mode specified by mode
posix_getgrnam()
Syntax
array posix_getgrnam(string name);
Description
The posix_getgrnam() function returns an associative array with information about the group defined in name The associative array contains the entries listed in Table 9.14
Table 9.14 Associative Array Returned by posix_getgrnam()
gid The numeric group ID for the group
number[n] The member list for the group
members The number of members in the group
posix_getgrgid()
Syntax
array posix_getgrgid(int gid);
Description
The posix_getgrgid() function returns an associative array with information about the group defined by the numeric gid (group ID) The associative array contains the
entries listed in Table 9.15
Table 9.15 Associative Array Returned by posix_getgrnam()
gid The numeric group ID for the group
Trang 2number[n] The member list for the GID
members The number of members in the GID
posix_getpwnam()
Syntax
array posix_getpwnam(string name);
Description
The posix_getpwnam() function returns an associative array with information about the username defined by name (see Table 9.16) This is the same information that is contained in the /etc/passwd file
Table 9.16 Associative Array Returned by posix_getpwnam()
name The username for the user
passwd The encrypted password for the user
uid The user ID for the user
gid The group ID for the user
gecos The real name for the user
dir The user's home directory
shell The user's preferred shell
posix_getpwuid()
Syntax
array posix_getpwuid(int uid);
Description
The posix_getpwuid() function returns an associative array with information about the username defined by uid (see Table 9.17) This is the same information that is contained in the /etc/passwd file
Table 9.17 Associative Array Returned by posix_getpwnam()
name The username for the uid
passwd The encrypted password for the uid
uid The user ID for the uid
Trang 3gid The group ID for the uid
gecos The real name for the uid
dir The uid's home directory
shell The uid's preferred shell
posix_getrlimit()
Syntax
array posix_getrlimit(void);
Description
The posix_getrlimit() function returns an associative array about the resource limits of the operating system The associative array returns the items listed in Table 9.18
Table 9.18 Associative Array Returned by posix_getrlimit()
stack Maximum stack size
virtualmem Maximum virtual memory size
totalmem Total system memory
>rss Maximum resident set size
maxproc Maximum number of processes
memlock Maximum locked-in-memory address space
filesize Maximum file size
openfiles Maximum number of open files
Program Execution
This section describes functions that allow external programs to return information to PHP These functions differ in the way they return information to PHP, to the browser, or how they format the output These are very powerful functions and allow PHP to employ any external executable that is available to the operating system
escapeshellcmd()
Syntax
string escapeshellcmd(string command);
Trang 4Description
The escapeshellcmd() function escapes any characters in the string command
Escaping characters places backslashes in front of special characters before they are passed to the exec() or system() function
exec()
Syntax
string exec(string command, string [array], int [return_var]);
Description
The exec() function executes the given command and returns the last line from the
result of the execution The optional argument array will contain the entire output of
the command The optional argument return_val will return the actual return the
status of the command
passthru()
Syntax
string passthru(string command, int [return_var]);
Description
The passthru() function executes the command and passes binary data, such as an
image stream, directly back to the browser The optional parameter return_var will
return the status of the UNIX command
system()
Syntax
string system(string command, int [return_var]);
Description
Trang 5The system() function executes the given command and returns the last line of the
command's result The optional parameter return_var will contain the result status
of the command
Semaphore and Shared Memory
This section describes the functions that are used to manage shared memory Shared memory provides an efficient method of sharing memory between multiple processes Because the data resides in the same physical RAM space and is accessible to multiple processes, a method must be devised to allow synchronous access to this memory This method is achieved through the use of semaphores that provide synchronous access to shared memory segments by multiple processes and applications
This section assumes that you have a thorough understanding of semaphores and shared memory and the methods, processes, and techniques used to acquire semaphores and shared memory
sem_get()
Syntax
int sem_get(int key, int [max_acquire], int [perm]);
Description
The sem_get() function returns a semaphore ID that can be used to access semaphore defined by key The optional parameter max_acquire is used to define
the maximum number of processes that can acquire the semaphore at the same time The optional parameter perm sets the permission bits for the semaphore The
default is 0666, read/write The function returns false, 0, if an error occurred
Note
Calling sem_get() a second time will return a different semaphore ID However, both identifiers access the same semaphore
sem_acquire()
Syntax
int sem_acquire(int sem_identifier);