ubuntu下ulimit -t
我正在运行 Ubuntu Linux (2.6.28-11-generic #42-Ubuntu SMP Fri Apr 17 01:57:59 UTC 2009 i686 GNU/Linux),命令“ulimit -t”似乎无法正常工作。 我跑了:
ulimit -t 1; myprogram
其中“myprogram”是无限循环。 我预计程序会在1秒后中断,但它并没有停止。 我在 Linux Fedora 安装上尝试了同样的操作,它按预期工作。
是否需要设置一些配置才能使其正常工作?
-- tsf
I am running Ubuntu Linux (2.6.28-11-generic #42-Ubuntu SMP Fri Apr 17 01:57:59 UTC 2009 i686 GNU/Linux) and it seems that the command "ulimit -t" does not work properly. I ran:
ulimit -t 1; myprogram
where 'myprogram' is an endless loop. I expected the program to be interrupted after 1 second, but it did not stop. I tried the same thing on a Linux Fedora installation and it worked as expected.
Is there some configuration that has to be set for it to work properly?
-- tsf
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如 Tsf 指出的,问题是由于 内核 2.6.28 中的错误。
我留下了原来的答案,因为我认为无论如何它都会有帮助。
来自 ulimit 联机帮助页
对于 ulimit 而言,重要的只是CPU 时间。
尝试像这样启动你的程序:
这将显示它实际使用了多少 CPU 时间。
我怀疑你的无限循环包含
sleep()
并且睡眠时间不影响进程的CPU时间。
一秒后就会被杀死:
这似乎会永远运行(但当然不会):
像这样测量 CPU 时间...
...5 秒后...
...仅使用 12 ms CPU 时间。
我在 ubuntu Jaunty Jackalope (9.04) 上尝试过
As Tsf pointed out, the problem is due to a bug in kernel 2.6.28.
I leave my original answer, because I think it could be helpful anyway.
From the ulimit manpage
What counts in respect to ulimit is only CPU time.
Try to start your program like this:
That will show you how much CPU time it really uses.
My suspicion is that your endless loop contains
sleep()
and sleep time does not contribute to the CPU time of the process.
This gets killed after one second:
This seems to run forever (but of course does not):
Measure CPU time like this...
...and 5 seconds later...
...only 12 ms CPU time used.
I tried it on ubuntu Jaunty Jackalope (9.04)