我目前有分叉两个进程的代码。第一个读取 http 流广播并将数据推送到管道(以 开头pipe()
),以便第二个进程使用 OSS 读取、解码并输出到声卡。
我一直在尝试调试解码部分(单独的问题),并且遇到了这样一种情况,即当我打印管道时,它的文件描述符为 0。据我所知,这意味着标准输入。这是管道的一个已知问题,它可能会意外打开一个标准文件描述符吗?如果是这样,我该如何解决?
我的管道/叉代码如下。还有很多其他代码,我希望它们无关紧要。
//this is the "switch channel" loop
while(1)
{
/*create the pipes
*
* httpPipe is for transfer of the stream between the readProcess and the playProcess
*
* playPPipe is for transfer of commands from the main process to the playProcess
*
* readPPipe is for transfer of commands from the main process to the readProcess
*
*/
if(pipe(httpPipe) == -1)
{
cout << "ERROR:: Error creating httpPipe: " …
Run Code Online (Sandbox Code Playgroud)