File tree 4 files changed +46
-3
lines changed
src/Symfony/Component/Process
4 files changed +46
-3
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ CHANGELOG
6
6
7
7
* added the ` Process::isTtySupported() ` method that allows to check for TTY support
8
8
* made ` PhpExecutableFinder ` look for the ` PHP_BINARY ` env var when searching the php binary
9
+ * added the ` ProcessSignaledException ` class to properly catch signaled process errors
9
10
10
11
4.0.0
11
12
-----
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony \Component \Process \Exception ;
13
+
14
+ use Symfony \Component \Process \Process ;
15
+
16
+ /**
17
+ * Exception that is thrown when a process has been signaled.
18
+ *
19
+ * @author Sullivan Senechal <soullivaneuh@gmail.com>
20
+ */
21
+ final class ProcessSignaledException extends RuntimeException
22
+ {
23
+ private $ process ;
24
+
25
+ public function __construct (Process $ process )
26
+ {
27
+ $ this ->process = $ process ;
28
+
29
+ parent ::__construct (sprintf ('The process has been signaled with signal "%s". ' , $ process ->getTermSignal ()));
30
+ }
31
+
32
+ public function getProcess (): Process
33
+ {
34
+ return $ this ->process ;
35
+ }
36
+
37
+ public function getSignal (): int
38
+ {
39
+ return $ this ->getProcess ()->getTermSignal ();
40
+ }
41
+ }
Original file line number Diff line number Diff line change 14
14
use Symfony \Component \Process \Exception \InvalidArgumentException ;
15
15
use Symfony \Component \Process \Exception \LogicException ;
16
16
use Symfony \Component \Process \Exception \ProcessFailedException ;
17
+ use Symfony \Component \Process \Exception \ProcessSignaledException ;
17
18
use Symfony \Component \Process \Exception \ProcessTimedOutException ;
18
19
use Symfony \Component \Process \Exception \RuntimeException ;
19
20
use Symfony \Component \Process \Pipes \PipesInterface ;
@@ -387,7 +388,7 @@ public function wait(callable $callback = null)
387
388
}
388
389
389
390
if ($ this ->processInformation ['signaled ' ] && $ this ->processInformation ['termsig ' ] !== $ this ->latestSignal ) {
390
- throw new RuntimeException ( sprintf ( ' The process has been signaled with signal "%s". ' , $ this -> processInformation [ ' termsig ' ]) );
391
+ throw new ProcessSignaledException ( $ this );
391
392
}
392
393
393
394
return $ this ->exitcode ;
Original file line number Diff line number Diff line change @@ -688,8 +688,8 @@ public function testProcessIsSignaledIfStopped()
688
688
}
689
689
690
690
/**
691
- * @expectedException \Symfony\Component\Process\Exception\RuntimeException
692
- * @expectedExceptionMessage The process has been signaled
691
+ * @expectedException \Symfony\Component\Process\Exception\ProcessSignaledException
692
+ * @expectedExceptionMessage The process has been signaled with signal "9".
693
693
*/
694
694
public function testProcessThrowsExceptionWhenExternallySignaled ()
695
695
{
You can’t perform that action at this time.
0 commit comments