非阻塞版本的system() [英] Non-blocking version of system()
本文介绍了非阻塞版本的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屋!
查看全文