Program that read file and send it to parent process with pipe

前端 未结 3 1402
小蘑菇
小蘑菇 2021-01-15 06:46

I need to write a program that create pipe send filename from command line to child process. In child read that file and send it back using pipe. Parent process should print

3条回答
  •  盖世英雄少女心
    2021-01-15 07:39

    This code does not compile:

      while (fgets(buff, sizeof(buff), file) != NULL) {
            write(pipefd[1], "Error reading file", 18);
         } else {
            write(pipefd[1], buff, sizeof(buff));
         }
    

    You can't have an else clause there.

提交回复
热议问题