写到标准输出和放大器;一份文件 [英] Writing to both stdout & a file
本文介绍了写到标准输出和放大器;一份文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个父进程,叉出一个孩子来执行execv()。
I have a parent process which forks out a child to perform execv().
我需要通过execv给予()的输出到标准输出到显示屏幕上的也被复制到一个日志文件。
I need the output given by execv() to stdout to be displayed onscreen as also copied to a log file.
我怎样写输出到标准输出和放大器一样的;一个文件,不使用管道或三通
How do I write the same output to both stdout & a file, without using pipes or tees?
推荐答案
如果你不想用一个发球,你写数据之前,把它写入一个文件,然后将其发送到标准输出。
If you don't want to use a tee, before you write the data, write it to a file, then send it to stdout.
您应该写日志记录功能,可以实现这个要求,使其更清洁。
You should write a logging function that does this for you to make it cleaner.
这篇关于写到标准输出和放大器;一份文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文