@@ -1255,7 +1255,14 @@ public static function isTtySupported(): bool
1255
1255
static $ isTtySupported ;
1256
1256
1257
1257
if (null === $ isTtySupported ) {
1258
- $ isTtySupported = (bool ) @proc_open ('echo 1 >/dev/null ' , [['file ' , '/dev/tty ' , 'r ' ], ['file ' , '/dev/tty ' , 'w ' ], ['file ' , '/dev/tty ' , 'w ' ]], $ pipes );
1258
+ $ handle = @proc_open ('echo 1 >/dev/null ' , [['file ' , '/dev/tty ' , 'r ' ], ['file ' , '/dev/tty ' , 'w ' ], ['file ' , '/dev/tty ' , 'w ' ]], $ pipes );
1259
+ $ isTtySupported = (bool ) $ handle ;
1260
+ if (false !== $ handle ) {
1261
+ fclose ($ pipes [0 ]);
1262
+ fclose ($ pipes [1 ]);
1263
+ fclose ($ pipes [2 ]);
1264
+ proc_close ($ handle );
1265
+ }
1259
1266
}
1260
1267
1261
1268
return $ isTtySupported ;
@@ -1278,7 +1285,16 @@ public static function isPtySupported()
1278
1285
return $ result = false ;
1279
1286
}
1280
1287
1281
- return $ result = (bool ) @proc_open ('echo 1 >/dev/null ' , [['pty ' ], ['pty ' ], ['pty ' ]], $ pipes );
1288
+ $ handle = @proc_open ('echo 1 >/dev/null ' , [['pty ' ], ['pty ' ], ['pty ' ]], $ pipes );
1289
+ $ result = (bool ) $ handle ;
1290
+ if (false !== $ handle ) {
1291
+ fclose ($ pipes [0 ]);
1292
+ fclose ($ pipes [1 ]);
1293
+ fclose ($ pipes [2 ]);
1294
+ proc_close ($ handle );
1295
+ }
1296
+
1297
+ return $ result ;
1282
1298
}
1283
1299
1284
1300
/**
@@ -1517,8 +1533,12 @@ private function doSignal(int $signal, bool $throwException): bool
1517
1533
$ ok = @proc_terminate ($ this ->process , $ signal );
1518
1534
} elseif (\function_exists ('posix_kill ' )) {
1519
1535
$ ok = @posix_kill ($ pid , $ signal );
1520
- } elseif ($ ok = proc_open (sprintf ('kill -%d %d ' , $ signal , $ pid ), [2 => ['pipe ' , 'w ' ]], $ pipes )) {
1536
+ } elseif ($ handle = proc_open (sprintf ('kill -%d %d ' , $ signal , $ pid ), [2 => ['pipe ' , 'w ' ]], $ pipes )) {
1521
1537
$ ok = false === fgets ($ pipes [2 ]);
1538
+ fclose ($ pipes [2 ]);
1539
+ proc_close ($ handle );
1540
+ } else {
1541
+ $ ok = false ;
1522
1542
}
1523
1543
if (!$ ok ) {
1524
1544
if ($ throwException ) {
0 commit comments