Limiting the time a program runs in Linux

后端 未结 7 1790
礼貌的吻别
礼貌的吻别 2020-12-23 11:39

In Linux I would like to run a program but only for a limited time, like 1 second. If the program exceeds this running time I would like to kill the process and show an erro

相关标签:
7条回答
  • 2020-12-23 12:17

    Ok, so just write a short C program that forks, calls execlp or something similar in the child, measures the time in the parent and kills the child. Should be easy ...

    0 讨论(0)
提交回复
热议问题