perl信号INT的问题

前端之家收集整理的这篇文章主要介绍了perl信号INT的问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在 windows activestate perl 5.8上有以下perl代码

$SIG{INT}=\&clean;

  ...
  sub clean {

  print 'cleaning...';
  ...
  ...
  exit 0;

  }

但是当我尝试通过Ctrl ^ c关闭我的程序时它根本没有进入子清洁可能有人帮助我为什么会错过什么?

解决方法

似乎Windows不像Unix那样提供信号.

来自man perlwin32:

Signal handling may not behave as on Unix platforms (where it doesn’t exactly “behave”,either :). For instance,calling “die()” or “exit()” from signal handlers will cause an exception,since most implementations of “signal()” on Win32 are severely crippled. Thus,signals may work only for simple things like setting a flag variable in the handler. Using signals under this port should currently be considered unsupported.

猜你在找的Perl相关文章