我目前正在研究一個小外殼,並試圖執行由多個命令組成的作業(如「ls | sort」)。 由於排序程序似乎遇到了「錯誤的文件描述符」,所以我在重定向時遇到了問題。 下面的代碼: 第一個命令: if (pipe(job->tubes[num_comm]) == -1)
{
perror("Erreur création tube");
ex
我正在嘗試在Linux上的dup2。我的測試程序是:我打開一個管道,嘗試複製stdin到fifo寫入,dup stdout到fifo讀取,我希望當我運行這個程序時,stdin被寫入fifo,並且fifo自動將內容轉儲到標準輸出: #include<stdio.h>
#include<unistd.h>
int main(){
int pipefd[2];
pipe(pipe