1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-24 15:52:40 +01:00

Return STDIN, STDOUT, and STDERR file descriptors from parent process

Summary:
Ref T13675. When a process daemonizes, it needs to close these actual file descriptors, so the calling context must provide them.

Elsewhere, modify the embedded "arc" to provide them. Then use them in place of reopening the streams.

Test Plan: Ran locally with embedded "arc", will deploy for production hangs.

Maniphest Tasks: T13675

Differential Revision: https://secure.phabricator.com/D21804
This commit is contained in:
epriestley 2022-05-05 09:52:46 -07:00
parent 2969f24961
commit fc5b228db5

View file

@ -17,7 +17,7 @@ final class PhutilSystem extends Phobject {
*/ */
public static function getStdinHandle() { public static function getStdinHandle() {
if (self::$stdin === false) { if (self::$stdin === false) {
self::$stdin = self::newStdioHandle('php://stdin'); self::$stdin = self::getStdioHandle('STDIN');
} }
return self::$stdin; return self::$stdin;
@ -28,7 +28,7 @@ final class PhutilSystem extends Phobject {
*/ */
public static function getStdoutHandle() { public static function getStdoutHandle() {
if (self::$stdout === false) { if (self::$stdout === false) {
self::$stdout = self::newStdioHandle('php://stdout'); self::$stdout = self::getStdioHandle('STDOUT');
} }
return self::$stdout; return self::$stdout;
@ -39,7 +39,7 @@ final class PhutilSystem extends Phobject {
*/ */
public static function getStderrHandle() { public static function getStderrHandle() {
if (self::$stderr === false) { if (self::$stderr === false) {
self::$stderr = self::newStdioHandle('php://stderr'); self::$stderr = self::getStdioHandle('STDERR');
} }
return self::$stderr; return self::$stderr;
@ -63,15 +63,12 @@ final class PhutilSystem extends Phobject {
/** /**
* @task stdio * @task stdio
*/ */
private static function newStdioHandle($ref) { private static function getStdioHandle($ref) {
$ignored_mode = ''; if (defined($ref)) {
return constant($ref);
$handle = @fopen($ref, $ignored_mode);
if ($handle === false) {
return null;
} }
return $handle; return null;
} }
/** /**