- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
这是怎么回事?我以为 SIGINT 会被发送到前台进程组。
(我想,也许 system() 正在运行一个 shell,它正在为子进程创建一个新的进程组?有人能证实这一点吗?)
% perl
local $SIG{INT} = sub { print "caught signal\n"; };
system('sleep', '10');
然后按 ctrl+d,然后立即按 ctrl+c,注意永远不会打印“捕获信号”。
我觉得这是一件简单的事情...无论如何要解决这个问题?问题是,当通过系统运行一堆命令时,会导致按住 ctrl+c 直到所有迭代完成(因为 perl 永远不会获得 SIGINT)并且相当烦人...
如何解决这个问题? (我已经直接使用 fork() 进行了测试,我知道这是可行的……目前这不是一个可接受的解决方案)
更新:请注意,这与“休眠”无关,只是该命令需要任意长的时间才能运行,这相当可观比它周围的 perl 还要多。如此之多以至于按 ctrl+c 被发送到命令(因为它在前台进程组中?)并且以某种方式设法永远不会被发送到 perl。
最佳答案
来自 perldoc system :
Since SIGINT and SIGQUIT are ignored during the execution of system, if you expect your program to terminate on receipt of these signals you will need to arrange to do so yourself based on the return value.
@args = ("command", "arg1", "arg2");
system(@args) == 0
or die "system @args failed: $?"If you'd like to manually inspect system's failure, you can check all possible failure modes by inspecting $? like this:
if ($? == -1) {
print "failed to execute: $!\n";
}
elsif ($? & 127) {
printf "child died with signal %d, %s coredump\n",
($? & 127), ($? & 128) ? 'with' : 'without';
}
else {
printf "child exited with value %d\n", $? >> 8;
}Alternatively, you may inspect the value of ${^CHILD_ERROR_NATIVE} with the W*() calls from the POSIX module
关于linux - 为什么 SIGINT 没有在这里被捕获?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3247768/
我正在使用 Gunicorn 为 Django 应用程序提供服务,它工作正常,直到我将其超时时间从 30 秒更改为 900000 秒,我不得不这样做,因为我有一个用例需要上传和处理一个巨大的文件(过程
我有一个带有非常基本的管道的Jenkinsfile,它可以旋转docker容器: pipeline { agent { dockerfile { args '-u root' } } stag
在学习 MEAN 堆栈的过程中,我遇到了一个问题。每当我尝试使用 Passport 验证方法时,它都不会返回任何响应。我总是收到“localhost没有发送任何数据。ERR_EMPTY_RESPONS
在当今的大多数企业堆栈中,数据库是我们存储所有秘密的地方。它是安全屋,是待命室,也是用于存储可能非常私密或极具价值的物品的集散地。对于依赖它的数据库管理员、程序员和DevOps团队来说,保护它免受所
是否可以创建像图片上那样的边框?只需使用 css 边框属性。最终结果将是没 Angular 盒子。我不想添加额外的 html 元素。我只想为每个 li 元素添加 css 边框信息。 假设这是一个 ul
我是一名优秀的程序员,十分优秀!