php实现多进程,源文件:
<?php $pid = pcntl_fork(); if($pid == -1){ die('could not fork'); }else{ if ($pid) { var_dump('parent:'.$pid); exit('parent'); }else{ var_dump('child:'.$pid); exit('child'); } } ?>
但运行提示出错:
andy@AndyMacBookPro:/usr/local/webdata/andy/php/duojincheng$ php pcntl.php
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20100525/pcntl.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20100525/pcntl.so, 9): image not found in Unknown on line 0
PHP Fatal error: Call to undefined function pcntl_fork() in /usr/local/webdata/andy/php/duojincheng/pcntl.php on line 4
PHP Stack trace:
PHP 1. {main}() /usr/local/webdata/andy/php/duojincheng/pcntl.php:0
andy@AndyMacBookPro:/usr/local/webdata/andy/php/duojincheng$
这是因为我们本机的php环境中没有pcntl.so扩展,所以我们下面来为php安装此扩展:
首先了解下自己本机系统中的php-config在哪里:
Last login: Sun Sep 28 17:04:12 on ttys002
andy@AndyMacBookPro:~$ sudo find / -name php-config
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/bin/php-config
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
/Users/andy/Downloads/php-5.4.30/scripts/php-config
/usr/bin/php-config
/usr/local/bin/php-config
/usr/local/Cellar/php54/5.4.30/bin/php-config
andy@AndyMacBookPro:~$ ll /usr/bin/php-config
-rwxr-xr-x 1 root wheel 3672 9 22 09:37 /usr/bin/php-config*
andy@AndyMacBookPro:~$ ll /usr/local/bin/php-config
lrwxr-xr-x 1 andy admin 37 7 1 13:04 /usr/local/bin/php-config@ -> ../Cellar/php54/5.4.30/bin/php-config
andy@AndyMacBookPro:~$
查看/usr/bin/php-config:
1 #! /bin/sh
2
3 SED="/usr/bin/sed"
4 prefix="/usr"
5 datarootdir="/usr/php"
6 exec_prefix="${prefix}"
7 version="5.4.30"
8 vernum="50430"
9 include_dir="${prefix}/include/php"
10 includes="-I$include_dir -I$include_dir/main -I$include_dir/TSRM -I$include_dir/Zend -I$include_dir/ext -I$include_d ir/ext/date/lib"
11 ldflags=" -L/BinaryCache/FreeType/FreeType-18~1619/Root/usr/local/lib"
12 libs="-lresolv -lz -lexslt -ltidy -lresolv -ledit -lncurses -lldap -llber -liconv -liconv -lpng -lz -ljpeg -lcrypto -lssl -lcrypto -lcurl -lbz2 -lz -lpcre -lcrypto -lssl -lcrypto -lm -lxml2 -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_er r -lcurl -lxml2 -lfreetype -lz -lxml2 -lnetsnmp -lcrypto -lxml2 -lxml2 -lxml2 -lxml2 -lxml2 -lxml2 -lxml2 -lxslt"
13 extension_dir='/usr/lib/php/extensions/no-debug-non-zts-20100525'
14 man_dir=`eval echo /usr/share/man`
15 program_prefix=""
16 program_suffix=""
17 exe_extension=""
18 php_cli_binary=NONE
19 php_cgi_binary=NONE
20 configure_options=" '--prefix=/usr' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--disable-dependency-trac king' '--sysconfdir=/private/etc' '--with-apxs2=/usr/sbin/apxs' '--enable-cli' '--with-config-file-path=/etc' '--wit h-config-file-scan-dir=/Library/Server/Web/Config/php' '--with-libxml-dir=/usr' '--with-openssl=/usr' '--with-kerber os=/usr' '--with-zlib=/usr' '--enable-bcmath' '--with-bz2=/usr' '--enable-calendar' '--disable-cgi' '--with-curl=/us r' '--enable-dba' '--enable-ndbm=/usr' '--enable-exif' '--enable-fpm' '--enable-ftp' '--with-gd' '--with-freetype-di r=/usr/local' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local' '--enable-gd-native-ttf' '--with-icu-dir=/usr ' '--with-ldap=/usr' '--with-ldap-sasl=/usr' '--with-libedit=/usr' '--enable-mbstring' '--enable-mbregex' '--with-my sql=mysqlnd' '--with-mysqli=mysqlnd' '--without-pear' '--with-pdo-mysql=mysqlnd' '--with-mysql-sock=/var/mysql/mysql .sock' '--with-readline=/usr' '--enable-shmop' '--with-snmp=/usr' '--enable-soap' '--enable-sockets' '--enable-sqlit e-utf8' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--with-tidy' '--enable-wddx' '--with-xmlrpc' '--wi th-iconv-dir=/usr' '--with-xsl=/usr' '--enable-zend-multibyte' '--enable-zip' '--with-pcre-regex=/usr'"
21 php_sapis=" apache2handler cli fpm"
22
23 # Set php_cli_binary and php_cgi_binary if available
24 for sapiin$php_sapis;do
25 case$sapiin
26 cli)
27 php_cli_binary="${exec_prefix}/bin/${program_prefix}php${program_suffix}${exe_extension}"
28 ;;
29 cgi)
30 php_cgi_binary="${exec_prefix}/bin/${program_prefix}php-cgi${program_suffix}${exe_extension}"
31 ;;
32 esac
33 done
34
"/usr/bin/php-config" [readonly] 90L, 3672C
查看/usr/local/bin/php-config:
1 #! /bin/sh
2
3 SED="/usr/local/Library/ENV/4.3/sed"
4 prefix="/usr/local/Cellar/php54/5.4.30"
5 datarootdir="/usr/local/Cellar/php54/5.4.30/php"
6 exec_prefix="${prefix}"
7 version="5.4.30"
8 vernum="50430"
9 include_dir="${prefix}/include/php"
10 includes="-I$include_dir -I$include_dir/main -I$include_dir/TSRM -I$include_dir/Zend -I$include_dir/ext -I$include_d ir/ext/date/lib"
11 ldflags=" -L/usr/local/opt/zlib/lib -L/usr/local/opt/jpeg/lib -L/usr/local/opt/libpng/lib -L/usr/local/Cellar/freety pe/2.5.3_1/lib -L/usr/local/Cellar/libpng/1.6.10/lib -L/usr/local/opt/gettext/lib -L/usr/local/opt/unixodbc/lib"
12 libs=" -lz -lexslt -lresolv -ledit -lncurses -lldap -llber -liconv -liconv -lintl -lpng -lz -ljpeg -lcrypto -lssl - lcrypto -lcurl -lbz2 -lz -lcrypto -lssl -lcrypto -lm -lxml2 -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lcurl -lxml2 -lfreetype -lz -lbz2 -lpng16 -lodbc -lodbc -lxml2 -lnetsnmp -lcrypto -lxml2 -lxml2 -lxml2 -lxml2 -lxml2 -lxml2 -lxm l2 -lxslt "
13 extension_dir='/usr/local/Cellar/php54/5.4.30/lib/php/extensions/no-debug-non-zts-20100525'
14 man_dir=`eval echo /usr/local/Cellar/php54/5.4.30/share/man`
15 program_prefix=""
16 program_suffix=""
17 exe_extension=""
18 php_cli_binary=NONE
19 php_cgi_binary=NONE
20 configure_options=" '--prefix=/usr/local/Cellar/php54/5.4.30' '--localstatedir=/usr/local/var' '--sysconfdir=/usr/lo cal/etc/php/5.4' '--with-config-file-path=/usr/local/etc/php/5.4' '--with-config-file-scan-dir=/usr/local/etc/php/5. 4/conf.d' '--with-iconv-dir=/usr' '--enable-dba' '--with-ndbm=/usr' '--enable-exif' '--enable-soap' '--enable-wddx' '--enable-ftp' '--enable-sockets' '--enable-zip' '--enable-shmop' '--enable-sysvsem' '--enable-sysvshm' '--enable-sy svmsg' '--enable-mbstring' '--enable-mbregex' '--enable-bcmath' '--enable-calendar' '--with-zlib=/usr/local/opt/zlib ' '--with-ldap' '--with-ldap-sasl=/usr' '--with-xmlrpc' '--with-kerberos=/usr' '--with-gd' '--enable-gd-native-ttf' '--with-freetype-dir=/usr/local/opt/freetype' '--with-jpeg-dir=/usr/local/opt/jpeg' '--with-png-dir=/usr/local/opt/l ibpng' '--with-gettext=/usr/local/opt/gettext' '--with-snmp=/usr' '--with-libedit' '--with-unixODBC=/usr/local/opt/u nixodbc' '--with-pdo-odbc=unixODBC,/usr/local/opt/unixodbc' '--mandir=/usr/local/Cellar/php54/5.4.30/share/man' '--w ith-mhash' '--with-curl' '--with-bz2=/usr' '--disable-debug' '--with-openssl=/usr' '--with-xsl=/usr' '--with-apxs2=/ usr/sbin/apxs' '--libexecdir=/usr/local/Cellar/php54/5.4.30/libexec' '--with-mysql-sock=/tmp/mysql.sock' '--with-mys qli=mysqlnd' '--with-mysql=mysqlnd' '--with-pdo-mysql=mysqlnd' '--enable-pcntl'"
21 php_sapis=" apache2handler cli cgi"
22
23 # Set php_cli_binary and php_cgi_binary if available
24 for sapiin$php_sapis;do
25 case$sapiin
26 cli)
27 php_cli_binary="${exec_prefix}/bin/${program_prefix}php${program_suffix}${exe_extension}"
28 ;;
29 cgi)
30 php_cgi_binary="${exec_prefix}/bin/${program_prefix}php-cgi${program_suffix}${exe_extension}"
31 ;;
32 esac
33 done
34
35 # Determine which (if any) php binary is available
36 if test "$php_cli_binary"!= "NONE";then
37 php_binary="$php_cli_binary"
38 else
39 php_binary="$php_cgi_binary"
40 fi
41
42 # Remove quotes
43 configure_options=`echo$configure_options|$SED -e"s#'##g"`
44
45 case "$1"in
46 --prefix)
47 echo$prefix;;
48 --includes)
49 echo$includes;;
50 --ldflags)
51 echo$ldflags;;
52 --libs)
53 echo$libs;;
54 --extension-dir)
55 echo$extension_dir;;
56 --include-dir)
57 echo$include_dir;;
58 --php-binary)
59 echo$php_binary;;
60 --php-sapis)
61 echo$php_sapis;;
62 --configure-options)
63 echo$configure_options;;
64 --man-dir)
65 echo$man_dir;;
66 --version)
67 echo$version;;
68 --vernum)
69 echo$vernum;;
70 *)
71 cat << EOF
72 Usage: $0 [OPTION]
73 Options:
74 --prefix [$prefix]
75 --includes [$includes]
76 --ldflags [$ldflags]
77 --libs [$libs]
78 --extension-dir [$extension_dir]
79 --include-dir [$include_dir]
80 --man-dir [$man_dir]
81 --php-binary [$php_binary]
82 --php-sapis [$php_sapis]
83 --configure-options [$configure_options]
84 --version [$version]
85 --vernum [$vernum]
86 EOF
87 exit1;;
88 esac
89
90 exit 0
可以看出应该是/usr/local/bin/php-config 而不是 /usr/bin/php-config ,后者好像是个模板之类的东西。
然后我们就可以去编译php得到php的扩展pcntl :
andy@AndyMacBookPro:~/Downloads/php-5.4.30/ext/pcntl$ phpize
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
andy@AndyMacBookPro:~/Downloads/php-5.4.30/ext/pcntl$ ./configure --with-php-config=/usr/local/bin/php-config
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... i386-apple-darwin13.4.0
checking host system type... i386-apple-darwin13.4.0
checking target system type... i386-apple-darwin13.4.0
checking for PHP prefix... /usr/local/Cellar/php54/5.4.30
checking for PHP includes... -I/usr/local/Cellar/php54/5.4.30/include/php -I/usr/local/Cellar/php54/5.4.30/include/php/main -I/usr/local/Cellar/php54/5.4.30/include/php/TSRM -I/usr/local/Cellar/php54/5.4.30/include/php/Zend -I/usr/local/Cellar/php54/5.4.30/include/php/ext -I/usr/local/Cellar/php54/5.4.30/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/Cellar/php54/5.4.30/lib/php/extensions/no-debug-non-zts-20100525
checking for PHP installed headers prefix... /usr/local/Cellar/php54/5.4.30/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking whether to enable pcntl support... yes, shared
checking for fork... yes
checking for waitpid... yes
checking for sigaction... yes
checking for getpriority... yes
checking for setpriority... yes
checking for wait3... yes
checking for sigprocmask... yes
checking for sigwaitinfo... no
checking for sigtimedwait... no
checking for ld used by cc... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
checking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld... no
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 196608
checking command to parse /usr/bin/nm output from cc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking if cc supports -fno-rtti -fno-exceptions... yes
checking for cc option to produce PIC... -fno-common
checking if cc PIC flag -fno-common works... yes
checking if cc static flag -static works... no
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin13.4.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
andy@AndyMacBookPro:~/Downloads/php-5.4.30/ext/pcntl$ make && make install
/bin/sh /Users/andy/Downloads/php-5.4.30/ext/pcntl/libtool --mode=compile cc -I. -I/Users/andy/Downloads/php-5.4.30/ext/pcntl -DPHP_ATOM_INC -I/Users/andy/Downloads/php-5.4.30/ext/pcntl/include -I/Users/andy/Downloads/php-5.4.30/ext/pcntl/main -I/Users/andy/Downloads/php-5.4.30/ext/pcntl -I/usr/local/Cellar/php54/5.4.30/include/php -I/usr/local/Cellar/php54/5.4.30/include/php/main -I/usr/local/Cellar/php54/5.4.30/include/php/TSRM -I/usr/local/Cellar/php54/5.4.30/include/php/Zend -I/usr/local/Cellar/php54/5.4.30/include/php/ext -I/usr/local/Cellar/php54/5.4.30/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /Users/andy/Downloads/php-5.4.30/ext/pcntl/pcntl.c -o pcntl.lo
mkdir .libs
cc -I. -I/Users/andy/Downloads/php-5.4.30/ext/pcntl -DPHP_ATOM_INC -I/Users/andy/Downloads/php-5.4.30/ext/pcntl/include -I/Users/andy/Downloads/php-5.4.30/ext/pcntl/main -I/Users/andy/Downloads/php-5.4.30/ext/pcntl -I/usr/local/Cellar/php54/5.4.30/include/php -I/usr/local/Cellar/php54/5.4.30/include/php/main -I/usr/local/Cellar/php54/5.4.30/include/php/TSRM -I/usr/local/Cellar/php54/5.4.30/include/php/Zend -I/usr/local/Cellar/php54/5.4.30/include/php/ext -I/usr/local/Cellar/php54/5.4.30/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /Users/andy/Downloads/php-5.4.30/ext/pcntl/pcntl.c -fno-common -DPIC -o .libs/pcntl.o
/bin/sh /Users/andy/Downloads/php-5.4.30/ext/pcntl/libtool --mode=compile cc -I. -I/Users/andy/Downloads/php-5.4.30/ext/pcntl -DPHP_ATOM_INC -I/Users/andy/Downloads/php-5.4.30/ext/pcntl/include -I/Users/andy/Downloads/php-5.4.30/ext/pcntl/main -I/Users/andy/Downloads/php-5.4.30/ext/pcntl -I/usr/local/Cellar/php54/5.4.30/include/php -I/usr/local/Cellar/php54/5.4.30/include/php/main -I/usr/local/Cellar/php54/5.4.30/include/php/TSRM -I/usr/local/Cellar/php54/5.4.30/include/php/Zend -I/usr/local/Cellar/php54/5.4.30/include/php/ext -I/usr/local/Cellar/php54/5.4.30/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /Users/andy/Downloads/php-5.4.30/ext/pcntl/php_signal.c -o php_signal.lo
cc -I. -I/Users/andy/Downloads/php-5.4.30/ext/pcntl -DPHP_ATOM_INC -I/Users/andy/Downloads/php-5.4.30/ext/pcntl/include -I/Users/andy/Downloads/php-5.4.30/ext/pcntl/main -I/Users/andy/Downloads/php-5.4.30/ext/pcntl -I/usr/local/Cellar/php54/5.4.30/include/php -I/usr/local/Cellar/php54/5.4.30/include/php/main -I/usr/local/Cellar/php54/5.4.30/include/php/TSRM -I/usr/local/Cellar/php54/5.4.30/include/php/Zend -I/usr/local/Cellar/php54/5.4.30/include/php/ext -I/usr/local/Cellar/php54/5.4.30/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /Users/andy/Downloads/php-5.4.30/ext/pcntl/php_signal.c -fno-common -DPIC -o .libs/php_signal.o
/bin/sh /Users/andy/Downloads/php-5.4.30/ext/pcntl/libtool --mode=link cc -DPHP_ATOM_INC -I/Users/andy/Downloads/php-5.4.30/ext/pcntl/include -I/Users/andy/Downloads/php-5.4.30/ext/pcntl/main -I/Users/andy/Downloads/php-5.4.30/ext/pcntl -I/usr/local/Cellar/php54/5.4.30/include/php -I/usr/local/Cellar/php54/5.4.30/include/php/main -I/usr/local/Cellar/php54/5.4.30/include/php/TSRM -I/usr/local/Cellar/php54/5.4.30/include/php/Zend -I/usr/local/Cellar/php54/5.4.30/include/php/ext -I/usr/local/Cellar/php54/5.4.30/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -o pcntl.la -export-dynamic -avoid-version -prefer-pic -module -rpath /Users/andy/Downloads/php-5.4.30/ext/pcntl/modules pcntl.lo php_signal.lo
cc ${wl}-flat_namespace ${wl}-undefined ${wl}suppress -o .libs/pcntl.so -bundle .libs/pcntl.o .libs/php_signal.o
dsymutil .libs/pcntl.so || :
creating pcntl.la
(cd .libs && rm -f pcntl.la && ln -s ../pcntl.la pcntl.la)
/bin/sh /Users/andy/Downloads/php-5.4.30/ext/pcntl/libtool --mode=install cp ./pcntl.la /Users/andy/Downloads/php-5.4.30/ext/pcntl/modules
cp ./.libs/pcntl.so /Users/andy/Downloads/php-5.4.30/ext/pcntl/modules/pcntl.so
cp ./.libs/pcntl.lai /Users/andy/Downloads/php-5.4.30/ext/pcntl/modules/pcntl.la
----------------------------------------------------------------------
Libraries have been installed in:
/Users/andy/Downloads/php-5.4.30/ext/pcntl/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `DYLD_LIBRARY_PATH' environment variable
during execution
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /usr/local/Cellar/php54/5.4.30/lib/php/extensions/no-debug-non-zts-20100525/
andy@AndyMacBookPro:~/Downloads/php-5.4.30/ext/pcntl$ cd /usr/local/Cellar/php54/5.4.30/lib/php/extensions/no-debug-non-zts-20100525/
andy@AndyMacBookPro:/usr/local/Cellar/php54/5.4.30/lib/php/extensions/no-debug-non-zts-20100525$ ll
total 400
drwxr-xr-x 4 andy admin 136 9 28 18:53 ./
drwxr-xr-x 3 andy admin 102 7 23 15:51 ../
-rw-r--r-- 1 andy admin 172732 7 23 15:51 apc.so
-rwxr-xr-x 1 andy admin 26928 9 28 18:53 pcntl.so*
andy@AndyMacBookPro:/usr/local/Cellar/php54/5.4.30/lib/php/extensions/no-debug-non-zts-20100525$
然后我们就可以到后面的这个目录去寻找我们的扩展文件pcntl.so,然后我们把这个so文件copy一份儿到我们系统的php扩展目录中去就可以了。
目前的情况是这个目录恰巧就是我们本地php版本的扩展目录,所以就不用mv了。(后话:这是因为我们引用了php-config,目录当然统一了 >< ,我当时不知道)
然后我们要到php.ini中去修改文件加入:
849 extension=/usr/local/Cellar/php54/5.4.30/lib/php/extensions/no-debug-non-zts-20100525/pcntl.so
(
这里我们用的时绝对路径,是因为这不是php默认的扩展加载路径,我本地php扩展的默认加载路径是:
/usr/lib/php/extensions/
比如我本地加载mssql.so在这里:
/usr/lib/php/extensions/no-debug-non-zts-20100525/mssql.so
)
然后重启apache服务器,即可。
pcntl support | enabled |
---|
现在我们来执行最开始的脚本,执行了两次,结果如下:
andy@AndyMacBookPro:/usr/local/webdata/andy/php/duojincheng$ php pcntl.php
string(11) "parent:5576"
string(7) "child:0"
parentchildandy@AndyMacBookPro:/usr/local/webdata/andy/php/duojincheng$ php pcntl.php
string(11) "parent:5619"
parentstring(7) "child:0"
childandy@AndyMacBookPro:/usr/local/webdata/andy/php/duojincheng$