2009-01-27から1日間の記事一覧

lsを実行して出力を得る

#include <stdio.h> #include <errno.h> #include <unistd.h> #define BUFFER_SIZE 512 static void ls() { int pfd[2]; pid_t pid; if (pipe(pfd) == -1) { perror("pipe"); exit(1); } pid = fork(); if (pid > 0) { // 親プロセス char buf[BUFFER_SIZE + 1]; int n, status; // 書き</unistd.h></errno.h></stdio.h>…