-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: refs hhvm/hsl#176 This part of enabling a pattern of: ``` list($stderr_parent, $stderr_child) = OS\socketpair(); // yep, stderr is read-write $stdin_child = OS\dup($stderr_child); OS\shutdown($stdin_child, OS\SHUT_WR); $stdout_child = OS\dup($stderr_child); OS\shutdown($stdout_child, OS\SHUT_RD); ``` `dup2()` is not necessary as we support explicitly remapping FDs when creating subprocesses `dup2()` is not desirable as: - Hack programs do not have insights to the real FD numbers. Especially in CLI server mode, STDIN/STDOUT/STDERR may not be on the canonical STDIN_FILENO/STDOUT_FILENO/STDERR_FILENO - Given that, there's a large risk of accidentally creating cross-request issues with `dup2()` Reviewed By: shayne-fletcher Differential Revision: D33166096 fbshipit-source-id: 41339a9a33c854982009086f3efdfc35277715c0
- Loading branch information
1 parent
9217447
commit ac00a11
Showing
5 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?hh // strict | ||
|
||
use namespace HH\Lib\_Private\_OS; | ||
|
||
<<__EntryPoint>> | ||
function main(): void { | ||
list ($r, $w1) = _OS\pipe(); | ||
$w2 = _OS\dup($w1); | ||
_OS\write($w2, "Hello, "); | ||
_OS\write($w1, "world.\n"); | ||
|
||
var_dump(_OS\read($r, 0xff)); | ||
_OS\close($w1); | ||
_OS\write($w2, "Hello again.\n"); | ||
_OS\close($w2); | ||
var_dump(_OS\read($r, 0xff)); | ||
var_dump(_OS\read($r, 0xff)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
string(14) "Hello, world. | ||
" | ||
string(13) "Hello again. | ||
" | ||
string(0) "" |