我正在使用命名管道来捕获另一个程序 (MATLAB) 中的外部程序 (wgrib2) 的输出。 MATLAB 代码如下,system()
访问命令行以制作管道:
system('mkfifo myfifo'); % Make a named pipe myfifo
% Call the external program wgrib2 and dump its output to the named pipe myfifo
system('wgrib2.exe multi_1.glo_30m.hs.201212.grb2 -ij 1 165 -ij 1 166 > myfifo &');
fid = fopen('myfifo', 'r'); % Open the named pipe
a = fscanf(fid, '%c'); % Read the output as character
fclose(fid); % Close the "file" (myfifo still exists afterward)
以下是我的问题:myfifo
在我使用它之后?代码运行后它似乎仍然存在。 myfifo
需要关闭,关闭它的命令是什么? 最佳答案
编辑以反射(reflect)以下评论,这是正确的。删除 != 关闭。
fclose(mFifo)
如已接受的答案中所述,关闭不会删除先进先出。您可能需要单独执行此操作。
关于matlab - 使用 mkfifo 打开的命名管道应该关闭吗?如何关闭?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14648974/