: UNIX

5.12.5

5.12.5

5.18 . , hello . , , , , , - .

char string[] = "hello";
main() {
char buf[1024];
char *cp1,*cp2;
int fds[2];
cp1 = string;
cp2 = buf;
while(*cp1) *cp2++ = *cp1++;
pipe(fds);
for (;;){
write(fds[1], buf, 6);
read(fds[0], buf, 6);
}
}

5.18.

, , 5.19, fifo. () , hello; , . , fifo, . ( ).

#include fcntl.h
char string[] = "hello";
main(argc, argv)
int argc;
char *argv[];
{
int fd;
char buf[256];
/* */
mknod("fifo", 010777, 0);
if (argc== 2)fd = open("fifo", O_WRONLY);
elsefd = open("fifo", O_RDONLY);
for (;;)
if (argc== 2) write(fd, string, 6);
elseread(fd, buf, 6);
}

5.19.


: 0.097. /Cache: 5 / 0