system() 调用行为 [英] system() call behavior

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

问题描述

我正在使用 system() 调用来启动tail -f".

I am using system() call to start "tail -f".

我看到的一件事是,tail 的调用需要 2 个进程(我可以在 ps 中看到):1) sh -c 尾文件名2) 尾部文件名

One thing I saw was that, invocation of tail takes 2 processes (I can see in ps): 1) sh -c tail filename 2) tail filename

正如手册页所说:system() 通过调用/bin/sh -c 命令执行 command 中指定的命令.我想,过程 1) 是不可避免的,对吗?

As man page says: system() executes a command specified in command by calling /bin/sh -c command. I guess, process 1) is inevitable, correct?

我只是想知道是否可以将进程数从 2 减少到 1.

I was just wondering if I can reduce number of processes from 2 to 1.

提前致谢.

推荐答案

system 总是执行 sh -c 命令.如果只需要一个进程,请执行 system("exec tail -f").

system always does sh -c command. If you want only one process, do system("exec tail -f").

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

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