3-3进程exec
pcntl_exec 函数用来执行一个程序,它内部的系统调用是 execve 一般的用法是父进程先创建一个子进程,然后子进程调用这个函数,正文段(代码段)+ 数据段会被新程序替换,它的一些属性会继承父进程,PID并没有发生变化。 execve() executes the program referred to by pathname. This causes the program that is currently being run by the calling process to be replaced with a new program, with newly initialized stack, heap, and (initialized and uninitialized) data segments. pathname must be either a binary executable, or a script starting with a line of the form: #!interpreter [optional-arg] ——execve 示例: demo7.php <?php function showID($str) { $pid = posix_getpid(); fprintf( STDOUT, "%s pid=%d,ppid=%d,gpid=%d,sid=%d,uid=%d,gid=%d\n", $str, $pid, posix_getppid(), posix_getpgrp(), posix_getsid($pid), posix_getuid(), posix_getgid() ); } showID("parent:"); $pid = pcntl_fork(); if (0 == $pid) { pcntl_exec('/usr/bin/php', ['demo2....