Pas*_*uoq 1 unix linux bash shell
如何在Bash中将进程限制为少于1秒的CPU时间?我使用的是版本4.1.5(1),如果我输入ulimit -t 0.5 command,我得到:
-bash: ulimit: 0.5: invalid number
Run Code Online (Sandbox Code Playgroud)
我使用的ulimit -t 1 command是一个不完美的替代品,但由于技术原因我不需要打扰你,我非常希望command在它有一个半秒或者可能少一点的CPU后停止.
特定于Linux的答案会很好.
也许你不能.底层系统调用(setrlimit)仅提供全秒解析.
RLIMIT_CPU
CPU time limit in seconds. When the process reaches the soft
limit, it is sent a SIGXCPU signal. The default action for this
signal is to terminate the process. However, the signal can be
caught, and the handler can return control to the main program.
If the process continues to consume CPU time, it will be sent
SIGXCPU once per second until the hard limit is reached, at
which time it is sent SIGKILL.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1252 次 |
| 最近记录: |