抑制system()控制台输出 [英] Suppress system() console output

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

问题描述

我使用 system()来打开和关闭我的代码与之通信的外部程序。但是,每次我使用 system()函数,我得到控制台输出,如果我从一个普通的终端/ shell,例如调用程序。每次调用系统(killall [程序]&)我得到一个终止消息。有没有办法压制这种类型的输出?

I'm using system() to open and close an external program with which my code communicates. However, every time I use the system() function, I get the console output I would get if I was calling the program from a normal terminal/shell, e.g. every time I call system(killall [program] &) I get a Terminated message. Is there a way to suppress this type of outputs?

推荐答案

您应该使用 execlp 而不是系统;)

You should use execlp instead of system ;)

https://www.securecoding.cert.org/confluence/display/seccode/ENV04-C.+Do+not+call+system()+ if + you + do + not + need + a + command + processor

这篇关于抑制system()控制台输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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