Skip to content

Commit 5d95c4c

Browse files
Fix bug #5825 (#5826)
1 parent f83f569 commit 5d95c4c

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

ext-src/swoole_process.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ static PHP_METHOD(swoole_process, __construct) {
347347
}
348348
}
349349

350+
zend_update_property_long(swoole_process_ce, SW_Z8_OBJ_P(ZEND_THIS), ZEND_STRL("id"), process->id);
350351
zend_update_property(
351352
swoole_process_ce, SW_Z8_OBJ_P(ZEND_THIS), ZEND_STRL("callback"), ZEND_CALL_ARG(execute_data, 1));
352353
php_swoole_process_set_worker(ZEND_THIS, process, enable_coroutine, pipe_type);

tests/swoole_process/process_id.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
swoole_process: Github bug #5825
3+
--SKIPIF--
4+
<?php require __DIR__ . '/../include/skipif.inc'; ?>
5+
--FILE--
6+
<?php
7+
require __DIR__ . '/../include/bootstrap.php';
8+
9+
use Swoole\Process;
10+
for ($n = 1; $n <= 3; $n++) {
11+
$process = new Process(function ($process) use ($n) {
12+
Assert::same($process->id, $n);
13+
});
14+
Assert::same($process->id, $n);
15+
$process->start();
16+
}
17+
?>
18+
--EXPECT--

0 commit comments

Comments
 (0)