进程控制扩展 程序执行 程序执行 函数

<?php
//Resource Limits  名字 默认 可修改范围 更新日志 
//memory_limit  "128M" PHP_INI_ALL "8M" before PHP 5.2.0, "16M" in PHP 5.2.0 


//echo memory_get_peak_usage();//返回分配给 PHP 内存的峰值 
//echo "<br>";
//echo  memory_get_usage();//返回分配给 PHP 的内存量


/*
 * 进程控制扩展  系统程序执行类函数
 * 
escapeshellarg — 把字符串转码为可以在 shell 命令里使用的参数
escapeshellcmd — shell 元字符转义
exec — 执行一个外部程序
passthru — 执行外部程序并且显示原始输出
proc_close — 关闭由 proc_open 打开的进程并且返回进程退出码
proc_get_status — 获取由 proc_open 函数打开的进程的信息
proc_nice — 修改当前进程的优先级
proc_open — 执行一个命令,并且打开用来输入/输出的文件指针。
proc_terminate — 杀除由 proc_open 打开的进程
shell_exec — 通过 shell 环境执行命令,并且将完整的输出以字符串的方式返回。
system — 执行外部程序,并且显示输出
 * 
 * 
 * 
 */


//$dir ="/usr/local/nginx/html/";
//system('ls '.escapeshellarg($dir));//注意这些命令是在windows还是linux下执行,现在这个测试在linux下执行,直接回返回值

//当用户提供的数据传入此函数,使用 escapeshellarg() 或 escapeshellcmd() 来确保用户欺骗系统从而执行任意命令。

//echo exec('netstat');
//
//system('netstat -tnlp');

//echo passthru('netstat');//执行外部程序并且显示原始输出.查看源代码就可以看到了

//$output = shell_exec('ls');//执行shell挺好用的,但是只能使用你php的用户,用户组的权限命令
//echo "<pre>$output</pre>";
<?php

/*
 * 
 * 
pcntl_alarm — 为进程设置一个alarm闹钟信号
pcntl_errno — 别名 pcntl_strerror
pcntl_exec — 在当前进程空间执行指定程序
pcntl_fork — 在当前进程当前位置产生分支(子进程)。译注:fork是创建了一个子进程,父进程和子进程 
 * 都从fork的位置开始向下继续执行,不同的是父进程执行过程中,得到的fork返回值为子进程 号,而子进程得到的是0。
pcn
 * tl_get_last_error — Retrieve the error number set by the last pcntl function which failed
 *                      设定的检索错误数量最后一个pcntl函数失败的错误代码
 * 
 * 
pcntl_getpriority — 获取任意进程的优先级
pcntl_setpriority — 修改任意进程的优先级
pcntl_signal_dispatch — 调用等待信号的处理器
pcntl_signal — 安装一个信号处理器
pcntl_sigprocmask — 设置或检索阻塞信号
pcntl_sigtimedwait — 带超时机制的信号等待
pcntl_sigwaitinfo — 等待信号
pcntl_strerror — Retrieve the system error message associated with the given errno
 *               检索与给定的errno相关系统错误消息
 *  
 * 
pcntl_wait — 等待或返回fork的子进程状态
pcntl_waitpid — 等待或返回fork的子进程状态
pcntl_wexitstatus — 返回一个中断的子进程的返回代码
pcntl_wifexited — 检查状态代码是否代表一个正常的退出。
pcntl_wifsignaled — 检查子进程状态码是否代表由于某个信号而中断
pcntl_wifstopped — 检查子进程当前是否已经停止
pcntl_wstopsig — 返回导致子进程停止的信号
pcntl_wtermsig — 返回导致子进程中断的信号
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 */
















/*
 * 
 * 
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功能失败的错误数
 * 
posix_getcwd — Pathname of current directory
 *              当前目录的路径名
 * 
posix_getegid — Return the effective group ID of the current process
 *               返回当前进程的有效组ID
 * 
posix_geteuid — Return the effective user ID of the current process
 *               返回当前进程的有效用户ID
 * 
posix_getgid — Return the real group ID of the current process
 *               返回当前进程的实际组ID
 * 
posix_getgrgid — Return info about a group by group id
 *                 返回一组信息组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
 *                    获得处理进程控制过程组id
 * 
posix_getpgrp — Return the current process group identifier
 *               返回当前进程组标识符
 * 
posix_getpid — Return the current process identifier
 *                  返回当前进程标识符
 * 
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
 *                返回信息用户的用户id
 * 
posix_getrlimit — Return info about system resource limits
 *                   返回信息系统资源的限制
 * 
posix_getsid — Get the current sid of the process
 *              获取当前进程的sid
 * 
posix_getuid — Return the real user ID of the current process
 *               返回当前进程的用户ID
 * 
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)
 *                 创建一个fifo特殊文件(命名管道)
 * 
posix_mknod — Create a special or ordinary file (POSIX.1)
 *              创建一个特殊的或普通的文件(posix . 1的授权)
 * 
posix_setegid — Set the effective GID of the current process
 *                设置当前进程的有效的GID
 * 
posix_seteuid — Set the effective UID of the current process
 *               设置当前进程的有效UID
 * 
posix_setgid — Set the GID of the current process
 *                 设置当前进程的GID
 * 
posix_setpgid — Set process group id for job control
 *                  设置进程控制过程组id
 * 
posix_setsid — Make the current process a session leader
 *                  使当前进程一个会话领袖
 * 
posix_setuid — Set the UID of the current process
 *                设置当前进程的UID
 * 
posix_strerror — Retrieve the system error message associated with the given errno
 *                   检索与给定的errno相关系统错误消息
 * 
posix_times — Get process times
 *               获得进程时间
 * 
posix_ttyname — Determine terminal device name
 *                  确定终端设备名称
 * 
posix_uname — Get system name
 *             得到系统名称
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 */
原文地址:https://www.cnblogs.com/zx-admin/p/4381210.html