amphp / byte-stream

A non-blocking stream abstraction for PHP based on Amp.
https://amphp.org/byte-stream
MIT License
363 stars 31 forks source link

do not use stream_socket_shutdown #106

Closed withinboredom closed 1 year ago

withinboredom commented 1 year ago

If a PHP process is sharing a file-descriptor with another process/thread, the file-descriptor will be closed for every other process/thread using that descriptor -- when using stream_socket_shutdown and causes broken pipes. At least in Linux, this should not happen, instead, the OS maintains a list of listeners/writers and will only break the pipe once all listeners are gone. fclose respects this and doesn't forcibly close the pipe for all users of the pipe.

This is especially important when accepting sockets and handing them off to another process (think CGI) and then closing the PHP side.

closes #105