2021-04-02から1日間の記事一覧
つまり,次のプログラムは,lsコマンドの出力を標準出力に出すのではなく,foo.txtに書き込む. #include <fcntl.h> #include <stdio.h> #include <unistd.h> int main(void) { close(STDOUT_FILENO); int fd = open("foo.txt", O_CREAT | O_WRONLY, 0644); if (fd != STDOUT_FILENO) { p</unistd.h></stdio.h></fcntl.h>…