在多线程环境中使用Linux中的系统(命令“命令”)不起作用?

发布于 2025-02-10 16:16:13 字数 303 浏览 0 评论 0原文

我正在C程序中的多线程环境中使用System CMD,但是它总是返回-1给出错误“ no child crocess” 和Errorno 10

 void test()
 {
    int ret;
    system("df -h");
    printf("%s %d",strerror(errno), errorno);
 }


 void* foo(void* p){
  test();
  }

注意:此代码在多线程环境中,并且使用SIGQUIT,也使用了sigquit 。

I am using system cmd in multithreaded environment in c program but it is always returning -1 giving error "No Child process" and errorno 10

 void test()
 {
    int ret;
    system("df -h");
    printf("%s %d",strerror(errno), errorno);
 }


 void* foo(void* p){
  test();
  }

NOTE: This code is in multithreaded environmet and also SIGACTION, SIGQUIT are used.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文