Comments (6)
I was not able to reproduce this on macOS, but I was able to reproduce this on Ubuntu. The sh
process terminates in both, but on macOS join()
does not resolve until the child PHP process exits, whereas on Ubuntu join()
resolves as soon as the sh
process ends.
from process.
Thx for fix. But signals still broadcasted to child process. How i can prevent it ? I handled signals in my parent process and want to send it to child only from code.
from process.
Also signal handling not worked after that fix. I changed test.php scrip:
<?php
require __DIR__.'/vendor/autoload.php';
\Amp\Loop::run(function(){
$process = new \Amp\Process\Process("php test-process.php");
$pid = yield $process->start();
\Amp\ByteStream\pipe($process->getStdout(), \Amp\ByteStream\getStdout());
\Amp\ByteStream\pipe($process->getStderr(), \Amp\ByteStream\getStderr());
$onInterrupt = \Amp\Loop::onSignal(SIGINT, function ($reference) use ($process){
echo "sigterm\n";
yield new \Amp\Delayed(5000);
echo "terminating child\n";
$process->signal(SIGINT);
\Amp\Loop::cancel($reference);
});
$code = yield $process->join();
echo $code;
if(file_exists("/proc/{$pid}")) {
echo "Process still running\n";
}
yield new \Amp\Delayed(10000);
\Amp\Loop::cancel($onInterrupt);
});
As you can see:
- i started
test-process.php
- wait for sigint
- if sigint received then wait 5s and send it child
As i can see sigint briadcasted on step 2 but i can't send it manually on step 3. May be need to use posix_kill instead of proc_terminate ?
from process.
As i understand i cannot prevent SIGINT sent to process group. But problem with sending signal to children process from code still exist
from process.
Fix sending signals to the child process in d51bd9a using posix_kill
instead of proc_terminate
as you suggested, since the latter was sending the signal to the wrapper child instead of the target child. Obviously the Process::signal()
method is not commonly used since this wasn't caught sooner. Generally child signal handlers catch signals from the console which are forwarded to all children. As you discovered, there is no way to change that behavior unless you change the group ID of the child process.
from process.
Thx. I use Process::signal in my code.
from process.
Related Issues (20)
- amphp/process kills sub process on exit HOT 7
- Amphp gets stuck in and infinite loop doing nothing if firewall delays port access HOT 6
- Not running at windows HOT 3
- How to start background processes HOT 2
- Connection failed: Amp\TimeoutException: Operation timed out in amphp\amp\lib\functions.php:275 HOT 2
- ProcessException with message 'Could not determine PID' HOT 1
- not get response of a user define method HOT 2
- php8 on windows with error HOT 4
- SocketConnector fails to close sockets on PHP8/Win
- Application stucks when launch application that requires elevated privileges on Windows HOT 1
- php8 on windows with error HOT 5
- Zombie Processes HOT 3
- v2 not working on FPM while v1 does HOT 8
- Remove Amp\Process\Internal\Windows\Barrier?
- Catching STDERR output HOT 3
- Doesn't work with dg/bypass-finals HOT 1
- Exception "ProcessException: Received 0 of 5 expected bytes" when reading from stdout out of time HOT 10
- Process getting stuck because of a full STDOUT/STDERR pipe
- amphp/process 1.x on Windows: Trying to start a non-existent executable gets stuck forever HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from process.