Skip to content

Commit

Permalink
corrections, update dependency, bug fix from it
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechsTech committed Mar 13, 2023
1 parent 6beeb75 commit f4d1cbf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"require": {
"php": ">7.4",
"ext-ffi": "*",
"symplely/zend-ffi": "~0.12.3"
"symplely/zend-ffi": "~0.12.5"
},
"autoload": {
"files": [
Expand Down
21 changes: 4 additions & 17 deletions src/UVHandles.php
Original file line number Diff line number Diff line change
Expand Up @@ -1050,8 +1050,6 @@ public function spawn(
int $flags = \UV::PROCESS_WINDOWS_HIDE,
array $uid_gid = []
) {
$h = \zval_stack(2);

$process_options = \c_struct_type('uv_process_options_s', 'uv');
$process_options->memset(0, $process_options->sizeof());

Expand Down Expand Up @@ -1080,19 +1078,8 @@ public function spawn(
}
$this->streams = $streams;

/* process args */
$n = 0;
$hash_len = $h->macro(\ZE::ARRVAL_P)->nNumOfElements;
$commands = \ffi_char($command);
$command_args = \FFI::new('char*[' . ($hash_len + 2) . ']', false);
$command_args[$n] = $commands;

$n++;
foreach ($args as $value) {
$command_args[$n] = \ffi_char($value);
$n++;
}
$command_args[$n] = NULL;
\array_unshift($args, $command);
$command_args = \ffi_char_variadic(...$args);

/* process env */
$i = 0;
Expand All @@ -1109,7 +1096,7 @@ public function spawn(
$gid = \IS_LINUX && \array_key_exists('gid', $uid_gid) ? $uid_gid['gid'] : null;

$options = $process_options();
$options->file = $commands;
$options->file = $command_args[0];
$options->stdio = \uv_cast('uv_stdio_container_t*', $container);
$options->exit_cb = function (CData $process, int $exit_status, int $term_signal) use ($callback, $process_options) {
if (!\is_null($callback)) {
Expand All @@ -1125,7 +1112,7 @@ public function spawn(

$options->stdio_count = $stdio_count;
$options->env = \FFI::cast('char**', $zenv);
$options->args = \FFI::cast('char**', $command_args);
$options->args = $command_args;

if (\is_null($cwd)) {
$cwd = \uv_cwd();
Expand Down
2 changes: 1 addition & 1 deletion src/ext_uv.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function module_clear(): void

public function module_shutdown(int $type, int $module_number): int
{
if (!$this->module_destructor_linked) {
if (!$this->destructor_linked) {
$this->module_clear();
}

Expand Down

0 comments on commit f4d1cbf

Please sign in to comment.