Skip to content

Instantly share code, notes, and snippets.

@tokuhirom
Forked from mattn/gist:188420
Created September 17, 2009 09:30
Show Gist options
  • Save tokuhirom/188423 to your computer and use it in GitHub Desktop.
Save tokuhirom/188423 to your computer and use it in GitHub Desktop.
mattn: pipe() は Perl の場合、win32 でもうごきますか?
動きます。
-----------------------------------------
#!/usr/bin/perl -w
use IO::Handle;
pipe(PARENTREAD, PARENTWRITE);
pipe(CHILDREAD, CHILDWRITE);
PARENTWRITE->autoflush(1);
CHILDWRITE->autoflush(1);
if ($child = fork) {
close CHILDREAD;
close PARENTWRITE;
print CHILDWRITE "34+56;\n";
chomp($result = <PARENTREAD>);
print "白ヤギさんから答えが来た: $result\n";
close PARENTREAD;
close CHILDWRITE;
waitpid($child,0);
} else {
close PARENTREAD;
close CHILDWRITE;
chomp($calculation = <CHILDREAD>);
print "黒ヤギさんから計算式来た: $calculation\n";
$result = eval "$calculation";
print PARENTWRITE "$result\n";
close CHILDREAD;
close PARENTWRITE;
exit;
}
おお。すばらしい。ありがとうございます! -- tokuhirom
.section .data
message:
.ascii "<title>hok</title>\n"
.section .text
.global _start
_start:
movl $4,%eax
movl $1,%ebx
movl $message,%ecx
movl $19,%edx
int $0x80
_exit:
movl $1,%eax
movl $0,%ebx
int $0x80
hello.txt: hello.as
as -o hello.o hello.as
ld -o hello.txt hello.o
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment