swoole / swoole-src

🚀 Coroutine-based concurrency library for PHP
https://www.swoole.com
Apache License 2.0
18.25k stars 3.16k forks source link

`proc_open` failed because `Pty` is not supported in Swoole #5275

Closed bosunski closed 1 month ago

bosunski commented 2 months ago

Please answer these questions before submitting your issue.

  1. What did you do? If possible, provide a simple script for reproducing the error.

When I run this code:

<?php
Swoole\Runtime::setHookFlags(SWOOLE_HOOK_ALL);
Swoole\Coroutine\run(function () {
    $descriptorspec = [
        ['pty'],
        ['pty'],
        ['pty'],
    ];
    $process = proc_open(["echo", "1"], $descriptorspec, $pipes);

    var_dump($pipes);

    var_dump(fread($pipes[2], 8192));

    $return_value = proc_close($process);

    echo "command returned $return_value\n";
});

I got a warning and the process failed to start:

PHP Warning:  proc_open(): pty pseudo terminal not supported on this system

When I ran the same code without Swoole, it worked fine

<?php

$descriptorspec = [
  ['pty'],
  ['pty'],
  ['pty'],
];
$process = proc_open(["echo", "1"], $descriptorspec, $pipes);

var_dump($pipes);

var_dump(fread($pipes[2], 8192));

$return_value = proc_close($process);

echo "command returned $return_value\n";
  1. What did you expect to see?

Running process should work fine without warning and output 1

  1. What did you see instead?

    PHP Warning:  proc_open(): pty pseudo terminal not supported on this system
  2. What version of Swoole are you using (show your php --ri swoole)?

swoole

Swoole => enabled Author => Swoole Team team@swoole.com Version => 5.0.3 Built => Sep 26 2023 16:42:34 coroutine => enabled with boost asm context kqueue => enabled rwlock => enabled sockets => enabled openssl => OpenSSL 3.1.3 19 Sep 2023 dtls => enabled http2 => enabled json => enabled curl-native => enabled pcre => enabled zlib => 1.2.12 async_redis => enabled

Directive => Local Value => Master Value swoole.enable_coroutine => On => On swoole.enable_library => On => On swoole.enable_preemptive_scheduler => Off => Off swoole.display_errors => On => On swoole.use_shortname => Off => Off swoole.unixsock_buffer_size => 262144 => 262144


5. What is your machine environment used (show your `uname -a` & `php -v` & `gcc -v`) ?
```shell
Darwin XXXXX-MacBook-Pro.local 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000 arm64
PHP 8.2.16 (cli) (built: Feb 13 2024 15:22:59) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.16, Copyright (c) Zend Technologies
Apple clang version 15.0.0 (clang-1500.1.0.2.5)
Target: arm64-apple-darwin23.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin