Welcome! Log In Create A New Profile

Advanced

[PHP-DEV] Help please: child processes are not killed when PHP is done

Posted by O'Neil Delpratt 
Hi All,

I am experiencing a strange behaviour in my PHP extension. My setup: Ubuntu LTS 16, Apache 2.4, PHP 7.0.30 (tested with PHP 7.1.17) and latest Saxon-HE/C 64bit.

Observed behaviour is that Apache spawns a couple of child processes as soon as Saxon is invoked. Problem is that those child processes are not killed when PHP is done.

Code
<?php
// output current PID and number of threads
$pid = getmypid();
$child_threads = trim(`ls /proc/{$pid}/task | wc -l`);

echo "&lt;pre&gt;";
echo "Process ID :$pid".PHP_EOL;
echo "Number of threads: $child_threads".PHP_EOL;
echo str_repeat("-", 20).PHP_EOL;

$sax = new Saxon\SaxonProcessor();

// output number of threads again
$child_threads = trim(`ls /proc/{$pid}/task | wc -l`).PHP_EOL;
echo "Number of threads: $child_threads".PHP_EOL;
/>


Gives the output:

Process ID: 5591 Number of threads: 1 ——————— Number of threads: 9

Running that code snippet, I see that additional 9 child threads are running, but they stay alive until I manually kill them.

Source code of php extension: https://dev.saxonica.com/repos/archive/opensource/latest9.8/hec/Saxon.C.API/php7_saxon.cpp https://dev.saxonica.com/repos/archive/opensource/latest9.8/hec/Saxon.C.API/php7_saxon.cpp
From my investigation an internal library Excelsior Jet is creating the extra threads, which I need to release.


> On 17 May 2018, at 09:57, O'Neil Delpratt <[email protected]> wrote:
>
> Hi All,
>
> I am experiencing a strange behaviour in my PHP extension. My setup: Ubuntu LTS 16, Apache 2.4, PHP 7.0.30 (tested with PHP 7.1.17) and latest Saxon-HE/C 64bit.
>
> Observed behaviour is that Apache spawns a couple of child processes as soon as Saxon is invoked. Problem is that those child processes are not killed when PHP is done.
>
> Code
> <?php
> // output current PID and number of threads
> $pid = getmypid();
> $child_threads = trim(`ls /proc/{$pid}/task | wc -l`);
>
> echo "&lt;pre&gt;";
> echo "Process ID :$pid".PHP_EOL;
> echo "Number of threads: $child_threads".PHP_EOL;
> echo str_repeat("-", 20).PHP_EOL;
>
> $sax = new Saxon\SaxonProcessor();
>
> // output number of threads again
> $child_threads = trim(`ls /proc/{$pid}/task | wc -l`).PHP_EOL;
> echo "Number of threads: $child_threads".PHP_EOL;
> />
>
>
> Gives the output:
>
> Process ID: 5591 Number of threads: 1 ——————— Number of threads: 9
>
> Running that code snippet, I see that additional 9 child threads are running, but they stay alive until I manually kill them.
>
> Source code of php extension: https://dev.saxonica.com/repos/archive/opensource/latest9.8/hec/Saxon.C.API/php7_saxon.cpp https://dev.saxonica.com/repos/archive/opensource/latest9.8/hec/Saxon.C.API/php7_saxon.cpp


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Sorry, only registered users may post in this forum.

Click here to login