Skip to content

Commit

Permalink
Added pty support for proc_open function, fix #5275 (#5290)
Browse files Browse the repository at this point in the history
* support pty, fix #5275

* fix

* fix 2

* fix

* fix BC

* fix tests
  • Loading branch information
matyhtf authored Apr 9, 2024
1 parent 86c8fbd commit 4a73486
Show file tree
Hide file tree
Showing 6 changed files with 1,040 additions and 423 deletions.
1 change: 1 addition & 0 deletions ext-src/php_swoole_cxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ SW_API php_stream *php_swoole_create_stream_from_socket(php_socket_t _fd,
int domain,
int type,
int protocol STREAMS_DC);
SW_API php_stream *php_swoole_create_stream_from_pipe(int fd, const char *mode, const char *persistent_id STREAMS_DC);
SW_API php_stream_ops *php_swoole_get_ori_php_stream_stdio_ops();
SW_API void php_swoole_register_rshutdown_callback(swoole::Callback cb, void *private_data);

Expand Down
8 changes: 8 additions & 0 deletions ext-src/swoole_runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2006,6 +2006,14 @@ php_stream *php_swoole_create_stream_from_socket(php_socket_t _fd, int domain, i
return stream;
}

php_stream *php_swoole_create_stream_from_pipe(int fd, const char *mode, const char *persistent_id STREAMS_DC) {
#if PHP_VERSION_ID >= 80200
return _sw_php_stream_fopen_from_fd(fd, mode, persistent_id, false STREAMS_CC);
#else
return _sw_php_stream_fopen_from_fd(fd, mode, persistent_id STREAMS_CC);
#endif
}

php_stream_ops *php_swoole_get_ori_php_stream_stdio_ops() {
return &ori_php_stream_stdio_ops;
}
Expand Down
8 changes: 4 additions & 4 deletions src/coroutine/hook.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,11 @@ int swoole_coroutine_socket_create(int fd) {
int _fd = socket->get_fd();
if (sw_unlikely(_fd < 0)) {
return -1;
} else {
std::unique_lock<std::mutex> _lock(socket_map_lock);
socket_map[fd] = socket;
return 0;
}
socket->get_socket()->set_nonblock();
std::unique_lock<std::mutex> _lock(socket_map_lock);
socket_map[fd] = socket;
return 0;
}

int swoole_coroutine_socket_unwrap(int fd) {
Expand Down
Loading

0 comments on commit 4a73486

Please sign in to comment.