system() 的非阻塞版本 [英] Non-blocking version of system()

查看:64
本文介绍了system() 的非阻塞版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的 c 程序中启动一个进程,但我不想等待该程序完成.我可以使用 system() 启动该过程,但总是等待.有谁知道一旦进程开始就会返回的非阻塞"版本?

I want to launch a process from within my c program, but I don't want to wait for that program to finish. I can launch that process OK using system() but that always waits. Does anyone know of a 'non-blocking' version that will return as soon as the process has been started?

当原进程执行完毕后,子进程需要继续运行.

When the original process has finished executing, the child process needs to keep on running.

推荐答案

您的系统调用中有一个选项,请执行以下操作:

One option is in your system call, do this:

 system("ls -l &");

&在命令行参数的末尾分叉你已经启动的任务.

the & at the end of the command line arguments forks the task you've launched.

这篇关于system() 的非阻塞版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆