Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning: exec(): Unable to fork #675

Open
niceboyat opened this issue Jul 7, 2024 · 12 comments
Open

Warning: exec(): Unable to fork #675

niceboyat opened this issue Jul 7, 2024 · 12 comments

Comments

@niceboyat
Copy link

niceboyat commented Jul 7, 2024

win10下cmd运行:
swoole-cli -f ./test.php

test.php文件代码:
<?php exec('dir', $str, $code); ?>

出现这个错误:

Warning: exec(): Unable to fork [dir] in /usr/bin/test.php on line 1
@jingjingxyk
Copy link
Contributor

@jingjingxyk
Copy link
Contributor

jingjingxyk commented Jul 8, 2024

你试一下 shell_exec 是不是也不好使。
不添加 -f 参数也试试,是否也报错

@jingjingxyk
Copy link
Contributor

本项目应该是没有定义 PHP_WIN32 , 因为 windows cygwin 环境下构建,其实是类 linux 环境构建, 这是完整构建配置: https://github.com/swoole/swoole-cli/blob/main/sapi/scripts/cygwin/cygwin-config.sh

windows 原生构建 ,定义 PHP_WIN32 所在文件: https://github.com/php/php-src/blob/php-8.1.27/win32/build/confutils.js#L3227

  1. linux 原生构建 执行的是 ./buildconf --force ,具体文件: https://github.com/php/php-src/blob/php-8.1.27/buildconf.bat
  2. windows 原生构建 执行的是 buildconf.bat --f , 具体文件: https://github.com/php/php-src/blob/php-8.1.27/buildconf.bat

@jingjingxyk
Copy link
Contributor

windows 构建配置在这个目录: https://github.com/php/php-src/tree/php-8.1.27/win32/build

@jingjingxyk
Copy link
Contributor

可定制一下编译参数试试,找到这个文件 https://github.com/swoole/swoole-cli/blob/main/sapi/scripts/cygwin/cygwin-config.sh

添加这一行

export CFLAGS="-DZEND_WIN32=1 "

类似这个,实验一下,看能否解决
image

实验pr : https://github.com/swoole/swoole-cli/pull/680/files

@jingjingxyk
Copy link
Contributor

看 VCWD_POPEN 函数的定义: 位于 https://github.com/swoole/swoole-cli/tree/main/Zend/zend_virtual_cwd.h 文件

image

@jingjingxyk
Copy link
Contributor

jingjingxyk commented Jul 8, 2024

可实验添加的参数
参考: https://github.com/php/php-src/blob/php-8.1.27/win32/build/confutils.js#L3227

export CFLAGS="-DZEND_WIN32=1 -DPHP_WIN32=1 -DWIN32 "

@jingjingxyk
Copy link
Contributor

@jingjingxyk
Copy link
Contributor

@jingjingxyk
Copy link
Contributor

@niceboyat 你试试 不添加 -f 执行,报错吗?

@1808661305
Copy link

我测试不添加-f也不行

@niceboyat
Copy link
Author

我测试不添加-f也不行

辛苦了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants