rendered paste body#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
int
main(int argc, char **argv)
{
int tube[2];
int pid;
if (pipe (tube) < 0)
{
fprintf (stderr, "pipe error\n");
return EXIT_FAILURE;
}
pid = fork ();
switch (pid)
{
case -1:
fprintf (stderr, "fork error\n");
return EXIT_FAILURE;
break;
case 0:
close (tube[0]);
dup2 (tube[1], STDOUT_FILENO);
execlp ("ls", "ls", "-lR", "/dev", NULL);
break;
default:
close (tube[1]);
dup2 (tube[0], STDIN_FILENO);
execlp ("more", "more", NULL);
break;
}
return EXIT_SUCCESS;
}