Skip to content

Commit b84aea2

Browse files
committed
Avoid passing null to explode
1 parent 7d23c9e commit b84aea2

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/Context/FeatureContext.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -786,13 +786,15 @@ private static function terminate_proc( $master_pid ): void {
786786

787787
$output = shell_exec( "ps -o ppid,pid,command | grep $master_pid" );
788788

789-
foreach ( explode( PHP_EOL, $output ) as $line ) {
790-
if ( preg_match( '/^\s*(\d+)\s+(\d+)/', $line, $matches ) ) {
791-
$parent = $matches[1];
792-
$child = $matches[2];
793-
794-
if ( (int) $parent === (int) $master_pid ) {
795-
self::terminate_proc( (int) $child );
789+
if ( is_string( $output ) ) {
790+
foreach ( explode( PHP_EOL, $output ) as $line ) {
791+
if ( preg_match( '/^\s*(\d+)\s+(\d+)/', $line, $matches ) ) {
792+
$parent = $matches[1];
793+
$child = $matches[2];
794+
795+
if ( (int) $parent === (int) $master_pid ) {
796+
self::terminate_proc( (int) $child );
797+
}
796798
}
797799
}
798800
}

0 commit comments

Comments
 (0)