资源简介
Linux C编程从初学到精通》.(张繁).

代码片段和文件信息
#include
#include
#include
#include
#include
#define BUFSIZE PIPE_BUF /* PIPE_BUF:管道默认一次性读写的数据长度*/
void err_quit(char * msg)
{
printf ( msg );
exit(1);
}
int main(void)
{
int fd[2];
char buf[BUFSIZE] = “hello my brother!\n“; /* 缓冲区 */
pid_t pid;
int len;
if ( (pipe(fd)) < 0 ) /*创建管道*/
{
err_quit(“pipe failed\n“);
}
if ( (pid = fork()) < 0 ) /*创建第一个子进程*/
{
err_quit(“fork failed\n“);
}
else if ( pid == 0 ) /*子进程中*/
{
close ( fd[0] ); /*关闭不使用的文件描述符*/
write(fd[1] buf strlen(buf)); /*写入消息*/
exit(0);
}
if ( (pid = fork()) < 0 ) /*创建第二个子进程*/
{
err_quit(“fork failed\n“);
}
else if ( pid > 0 ) /*父进程中*/
{
close ( fd[0] );
close ( fd[1] );
exit ( 0 );
}
else /*第二个子进程中*/
{
close ( fd[1] ); /*关闭不使用的文件描述符*/
len = read (fd[0] buf BUFSIZE); /*读取消息*/
write(STDOUT_FILENO buf len); /*将消息输出到标准输出*/
exit(0);
}
return 0;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1335 2010-01-23 11:41 sample\chapter_10\brother_pipe.c
文件 604 2010-01-23 11:42 sample\chapter_10\create_FIFO.c
文件 666 2010-01-23 11:40 sample\chapter_10\create_pipe.c
文件 460 2010-01-23 11:49 sample\chapter_10\create_shm.c
文件 3613 2010-01-23 11:44 sample\chapter_10\msg_app.c
文件 1125 2010-01-23 11:41 sample\chapter_10\parent_pipe_child.c
文件 606 2010-01-23 16:29 sample\chapter_10\read_fifo.c
文件 632 2009-10-17 23:54 sample\chapter_10\read_shm.c
文件 4100 2010-01-23 22:59 sample\chapter_10\sem_app.c
文件 1121 2010-01-23 11:43 sample\chapter_10\write_fifo.c
文件 646 2009-10-17 23:52 sample\chapter_10\write_shm.c
文件 1157 2010-01-24 15:41 sample\chapter_11\bind.c
文件 1541 2009-10-24 11:05 sample\chapter_11\client_tcp.c
文件 1455 2009-10-25 21:11 sample\chapter_11\client_udp.c
文件 1800 2010-01-24 15:43 sample\chapter_11\lisn_acp.c
文件 5417 2009-10-27 22:16 sample\chapter_11\myping.c
文件 1177 2010-01-24 15:53 sample\chapter_11\remote_connect.c
文件 2029 2010-01-24 16:18 sample\chapter_11\remote_read.c
文件 1476 2010-01-24 16:08 sample\chapter_11\remote_recv.c
文件 2547 2009-10-24 10:59 sample\chapter_11\server_tcp.c
文件 1282 2009-10-25 21:09 sample\chapter_11\server_udp.c
文件 540 2010-01-25 17:21 sample\chapter_12\add_label.c
文件 842 2010-01-25 17:23 sample\chapter_12\button_example.c
文件 1519 2010-01-25 18:46 sample\chapter_12\check_radio.c
文件 1726 2010-01-25 18:44 sample\chapter_12\control_example.c
文件 2051 2009-10-31 22:24 sample\chapter_12\con_nested_table.c
文件 1415 2009-11-01 21:03 sample\chapter_12\dialog_example.c
文件 981 2010-01-25 17:24 sample\chapter_12\entry_example.c
文件 311 2010-01-25 17:19 sample\chapter_12\first_win.c
文件 777 2009-10-31 23:49 sample\chapter_12\hpaned_example.c
............此处省略109个文件信息
- 上一篇:单相逆变电源毕业设计可以实现到220V
- 下一篇:fastFDS 安装资源
相关资源
- WCE注入工具
- ModelGoon-4.4.1-site.zip
- AsyncTask文件控制暂停和继续,在状态
- Visio大全模具(含Cisco、IBM等常用拓扑
- 信号奇异点Lipschitz指数计算
- 基于STM32RCT6的步进电机驱动程序
- 酒店管理系统基于Qt Creator5)
- 用友NC开发API字典
- Navicat Premium 15汉化包.zip55438
- 登录注册界面.zip48872
- 条码字体barcode128
- Rational Rose Common破解文件
- res10_300x300_ssd_iter_140000.caffemodel与dep
- scratch 第1课 翻跟斗的小猫(入门)
- stm32f407上的两个can发送和接收例程
- Scrach 欢乐狙击手.sb2
- 04741计算机网络原理知识点整理.docx(
- Wolfram Mathematica 矩阵初等变换函数(
- pscad近海风电模型 Fortran语言
- 程序员专用字体YaHei.Consolas.1.11b42517
- scratch3.0 源程序(说相声)
- AutoCAD永久去教育版破解补丁
- 开源1A锂电池充电板TP4056原理图+PCB
- m1卡 ic卡可选择扇区初始化加密软件
- TSCC.exe
- 欧姆龙CP1系列单轴定位PLC程序.cxp
- 用Beckhoff(倍福)PLC读写巴鲁夫RFID
- CVSNT 完整覆盖版防TortoiseCVS中文乱码
- pfc 使用说明.doc
- Scratch 飞机大战.sb3
评论
共有 条评论