运行在后台的linuxÇ一个新的子进程 [英] Running a new child process in background C linux
问题描述
我想在后台运行一个新的进程,因此将有可能继续与父进程的工作。
I am trying to run a new process in background so it will be possible to continue working with parent process.
我用叉子然后EXECL。我试图添加到execl的命令的参数及放大器;但它不工作:
I used fork then execl. I tried to add to the execl command the argument & but it doesn't work:
execl("newproc","newproc","arg1","&",NULL);
请问有什么解决办法吗?
Is there any solution?
推荐答案
的问题是,&安培;
不是一个命令行选项来计划。相反,它是在后台将一个命令仅仅是特殊的shell语法。的后台程序的显着特点是,它们不连接到一个终端,并且终端没有等待的过程来完成。正确功能是守护进程()
。做一个男人守护
对如何使用它念起来。
The problem is that &
is not a command line option to programs. Instead, it is merely special shell syntax which puts a command in the background. The distinguishing feature of background programs is that they are not connected to a terminal, and the terminal is not waiting for the process to complete. The proper function is daemon()
. Do a man daemon
to read up on how it is used.
这篇关于运行在后台的linuxÇ一个新的子进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!