【发布时间】:2013-01-16 22:09:35
【问题描述】:
我正在使用命名管道在另一个程序 (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需要关闭,关闭的命令是什么? - 上面的代码示例我会运行很多次(>1000),所以如果我重用命名管道并且直到结束才关闭它可以吗?
【问题讨论】:
标签: matlab shell command pipe named-pipes