我有一个程序调用了一个tar命令,类似于popen("tar -zcvf")
我想要在stdin上写入并获得输出,类似于tar -zcvf - /path | tar -zxvf -
因此,一边封装目录中的文件并将它们通过stdout发送,另一边在反向进程中写入并发送到bash的stdout。
我想进行这个管道过程。
读取一个文件夹/文件,通过stdin发送内容以“提取”内容并读取二进制输出。
我想这样做,因为我可以通过套接字发送数据并在另一端提取,无需磁盘即时压缩和解压缩。
有人能帮我吗?
我发现需要使用execl...但是我找到的所有示例都是将子进程的stdout重定向到我的stdout。
我将执行类似以下的操作:
LOOP.
1 Get block of data from stdin
2 Send to child program
3 get the output
4 Do something with the data (send back trough socket)
END_LOOP
OR
LOOP
1 Get block of data from stdin.
2 Send to child program.
END_LOOP
LOOP
1 Get block of data from child program
2 Do something with the data (send back trough socket)
END_LOOP