Last active
November 18, 2019 03:19
-
-
Save kaz-utashiro/7084f773b14851466abf to your computer and use it in GitHub Desktop.
Perl で子プロセスが入力を読めない問題 ref: https://qiita.com/kaz-utashiro/items/80fc83e56e645f19e927
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
$_ = do { local $/; <> }; | |
if (open(CHLD, '|-') == 0) { | |
print <>; | |
exit; | |
} | |
print CHLD $_; |
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
$_ = do { local $/; <> }; | |
if (open(CHLD, '|-') == 0) { | |
exec "cat" or warn $!; | |
exit; | |
} | |
print CHLD $_; |
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
if (open(CHLD, '|-') == 0) { | |
print <>; | |
exit; | |
} | |
$_ = do { local $/; <> }; | |
print CHLD $_; |
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
@_ = <>; | |
if (open(CHLD, '|-') == 0) { | |
print <>; | |
exit; | |
} | |
print CHLD @_; |
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
@_ = <>; | |
warn "eof\n" if eof STDIN; | |
if (open(CHLD, '|-') == 0) { | |
print <>; | |
exit; | |
} | |
print CHLD @_; |
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
$_ = do { local $/; <> }; | |
if (open(CHLD, '|-') == 0) { | |
<> if eof STDIN; | |
print <>; | |
exit; | |
} | |
print CHLD $_; |
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
$_ = do { local $/; <> }; | |
if (open(CHLD, '|-') == 0) { | |
open STDIN, '<&', 0 if eof STDIN; | |
print <>; | |
exit; | |
} | |
print CHLD $_; |
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
$_ = do { local $/; <> }; | |
pipe PIN, POUT or die; | |
if (fork == 0) { | |
close STDIN; | |
open STDIN, '<&PIN'; | |
close PIN; | |
close POUT; | |
print <>; | |
exit; | |
} | |
close PIN; | |
print POUT $_; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment