【发布时间】:2022-10-24 09:23:23
【问题描述】:
我搜索答案,到目前为止还没有找到一个明确的答案。
我正在测试启动许多调用“system()”的线程,如下所示。
for (int i = 0; i < 3000; ++i)
pthread_create(&thread[i], NULL, thread_func, NULL);
for (int i = 0; i < 3000; ++i)
pthread_join(thread[i], NULL);
...
void* thread_func(void* arg)
{
if (system('test.sh') == -1)
{
perror("system");
exit(1);
}
pthread_exit(NULL);
}
测试.sh
#!/bin/bash
sleep 100
当我运行程序时,它会在某个时候显示。
system: Resource temporarily unavailable
有没有办法知道哪个资源?我修复了最大进程问题,所以我认为这可能是由于其他原因。
【问题讨论】:
-
更新
limits.conf后是否注销并重新登录? -
是的,我什至尝试重新启动仍然无法正常工作
-
OK,编辑“limits.conf”的方法不行。答案here 有效。
标签: linux process fork child-process ulimit