POSIX PHP

Kristian Koehntopp added a module to PHP to support the POSIX.1 standard, also known as IEEE 1003.1. This standard describes functionality provided to user processes by an operating system. A few functions in this section are not part of the standard, but are commonly available in System V or BSD UNIX systems.

Many of these functions are available only to the root user. PHP scripts are executed by the owner of the Web server process, which is usually a special user for just this purpose. Running the Web server as root is unusual and dangerous. Anyone able to view a PHP file through the Web server would have arbitrary control over the system. Keep in mind, however, that PHP can be compiled as a stand-alone executable. In this case it can be used like any other scripting language.

These functions are wrappers for underlying C functions, usually named by the part after the posix_ prefix. If you require detailed information, I suggest reading the man pages.

string posix_ctermid()
The posix_ctermid function returns the terminal path name.

<?
print("Terminal Path Name: " . posix_ctermid() . "<BR> ");
?>

string posix_getcwd()
The posix_getcwd function returns the current working directory.

<?
print ("Current Working Directory: " . posix_getcwd() . "<BR> ");
?>

integer posix_getegid()
The posix_getegid function returns the effective group ID of the calling process.

integer posix_geteuid()
The posix_geteuid function returns the effective user ID for the process running the PHP engine.

integer posix_getgid()
The posix_getgid function returns the ID of the current group.

array posix_getgrgiarray posix_getgrgid(integer group)d(integer group)
The posix_getgrgid function returns an array describing access to the group database. The elements of the returned array are gid, members, name, and an entry of each member of the group.

<?
$group = posix_getgrgid(posix_getgid());
print("Group: {$group['name']}<BR> ");
?>

array posix_getgrnam(string group)
The posix_getgrnam function returns an array describing access to the group database. The elements of the returned array are gid, members, name, and an entry of each member of the group.

array posix_getgroups()
The posix_getgroups function returns supplementary group IDs.

string posix_getlogin()
Use posix_getlogin to get the login name of the user executing the PHP engine.

integer posix_getpgid()
The posix_getpgid function returns the group ID for the user executing the PHP engine.

integer posix_getpgrp()
The posix_getpgrp function returns the current process group ID.
integer posix_getpid()
The posix_getpid function returns the process ID.

integer posix_getppid()
The posix_getppid function returns the process ID of the parent process.

array posix_getpwnam(string user)
The posix_getpwnam function returns an array describing an entry in the user database. The elements of the array are dir, gecos, gid, name, passwd, shell, and uid.

array posix_getpwuid(integer user)
The posix_getpwuid function returns an array describing an entry in the user database based on a given user ID. The elements of the array are dir, gecos, gid, name, passwd, shell, and uid. These are the same elements returned by posix_getpwnam.

array posix_getrlimit()
The posix_getrlimit function returns an array describing system resource usage. The array contains elements that begin with hard or soft followed by a space and one of the following limit names: core, cpu, data, filesize, maxproc, memlock, openfiles, rss, stack, totalmem, virtualmem.

posix_getrlimit

posix_getrlimit

integer posix_getsid()
The posix_getsid function returns the process group ID of the session leader.

integer posix_getuid()
The posix_getuid function returns the user ID of the user executing the PHP engine.

boolean posix_isatty (integer descriptor)
The posix_isatty function returns TRUE if the given file descriptor is a TTY.

boolean posix_kill(integer process, integer signal)
The posix_kill function sends a signal to a process.

boolean posix_mkfifo(string path, integer mode)
The posix_mkfifo function creates a FIFO file. The mode argument follows the same rules as chmod.

boolean posix_setgid(integer group)
Use posix_setgid to change the group for the current process. Only the root user may switch groups.

integer posix_setpgid(integer process, integer group)
The posix_setpgid function sets the process group ID for a given process.

integer posix_setsid()
The posix_setsid function creates a session and returns the process groupID.

boolean posix_setuid(integer user)
Use posix_setuid to change the user for the current process. Only the root user may change the user ID.

array posix_times()
The posix_times function returns an array of values on system clocks. The elements of the array are cstime, cutime, stime, ticks, and utime.

<?
foreach(posix_getrlimit() as $key=>$value)
{
print("$key: $value<BR> ");
}
?>

string posix_ttyname(integer descriptor)
The posix_ttyname function returns the name of the terminal device.

array posix_uname()
The posix_uname function returns an array of information about the system. The elements of the array are machine, nodename, release, sysname, and version.

posix_uname

posix_uname

posix_uname


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

PHP Topics