黑馬博學(xué)谷狂野架構(gòu)4期
? ?// 創(chuàng)建Pipe
? ?int p[2];
? ?prepare_pipe(p);
? ?// splice()將文件1字節(jié)數(shù)據(jù)寫入Pipe
? ?ssize_t nbytes = splice(fd, &offset, p[1], NULL, 1, 0);
? ?......
? ?// write()寫入任意數(shù)據(jù)到Pipe
? ?nbytes = write(p[1], data, data_size);
? ?// 判斷是否寫入成功
? ?if (nbytes < 0) {
? ? ? ?perror("write failed");
? ? ? ?return EXIT_FAILURE;
? ?}
標(biāo)簽: