我在 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 - perl 信号 INT 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4761443/