Perl 的 IO::Select 在 Windows 中使用文件句柄吗? [英] Does Perl's IO::Select in Windows work with filehandles?

查看:59
本文介绍了Perl 的 IO::Select 在 Windows 中使用文件句柄吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Windows 中的 IO::Select 是否使用文件句柄?

Does IO::Select in Windows work with filehandles?

$pid = open $handle, "-|", "$_command" || die "Cannot run $_command";
my $s = IO::Select->new();
$s->add($handle);
$s->add(\*STDIN);
while (1) {
    @ready = $s->can_read(30);
    if (scalar(@ready) > 0) {
    }
    else {
    }
}

我的脚本不断地在屏幕上打印一些东西,打开后,命令在后台启动,但 can_read 在 Windows 上总是失败.有什么帮助吗?

My script continuously prints something to the screen, with open, the command gets started in the background but can_read always fails on Windows. Any help?

推荐答案

请参阅此 PerlMonks 线程:

select(IO::Select 使用的底层系统调用)仅适用于 Windows 中的套接字.

select (the underlying system call used by IO::Select) only works for sockets in Windows.

MSDN docs for select 确认这一点:

select 函数确定一个或多个套接字的状态,必要时等待执行同步 I/O.

The select function determines the status of one or more sockets, waiting if necessary, to perform synchronous I/O.

这篇关于Perl 的 IO::Select 在 Windows 中使用文件句柄吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆