📄 linux环境进程间通信(一) 管道及有名管道.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0063)http://study.feloo.com/computer/pro/vc/system/200506/39159.html -->
<HTML><HEAD><TITLE>Linux环境进程间通信(一): 管道及有名管道</TITLE>
<META
content="Linux环境进程间通信(一): 管道及有名管道,Linux环境进程间通信(一): 管道及有名管道教程,Linux环境进程间通信(一): 管道及有名管道学习文章,Linux环境进程间通信(一): 管道及有名管道电脑教程,Linux环境进程间通信(一): 管道及有名管道电脑文章,Linux环境进程间通信(一): 管道及有名管道学习教程,Linux环境进程间通信(一): 管道及有名管道学习资料,Linux环境进程间通信(一): 管道及有名管道资料下载,Linux环境进程间通信(一): 管道及有名管道实例,Linux环境进程间通信(一): 管道及有名管道实例教学"
name=Description>
<META content='="Linux环境进程间通信(一):' name=keywords 管道及有名管道实例教学?
管道及有名管道实例,Linux环境进程间通信(一): 管道及有名管道资料下载,Linux环境进程间通信(一):
管道及有名管道学习资料,Linux环境进程间通信(一): 管道及有名管道学习教程,Linux环境进程间通信(一):
管道及有名管道电脑文章,Linux环境进程间通信(一): 管道及有名管道电脑教程,Linux环境进程间通信(一):
管道及有名管道学习文章,Linux环境进程间通信(一): 管道及有名管道教程,Linux环境进程间通信(一):
管道及有名管道,Linux环境进程间通信(一):>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<STYLE type=text/css>.style1 {
COLOR: #0099cc
}
</STYLE>
<LINK href="Linux环境进程间通信(一) 管道及有名管道.files/Skin3.css" type=text/css
rel=stylesheet>
<SCRIPT language=JavaScript src="Linux环境进程间通信(一) 管道及有名管道.files/menu.js"
type=text/JavaScript></SCRIPT>
<SCRIPT language=JavaScript1.2 src="Linux环境进程间通信(一) 管道及有名管道.files/stm31.js"
type=text/javascript></SCRIPT>
<SCRIPT language=JavaScript type=text/JavaScript>
//改变图片大小
function resizepic(thispic)
{
if(thispic.width>700) thispic.width=700;
}
//无级缩放图片笮?
function bbimg(o)
{
var zoom=parseInt(o.style.zoom, 10)||100;
zoom+=event.wheelDelta/12;
if (zoom>0) o.style.zoom=zoom+'%';
return false;
}
//双击鼠标滚动屏幕的代码
var currentpos,timer;
function initialize()
{
timer=setInterval ("scrollwindow ()",30);
}
function sc()
{
clearInterval(timer);
}
function scrollwindow()
{
currentpos=document.body.scrollTop;
window.scroll(0,++currentpos);
if (currentpos !=document.body.scrollTop)
sc();
}
document.onmousedown=sc
document.ondblclick=initialize
//更改字体大小
var status0='';
var curfontsize=10;
var curlineheight=18;
function fontZoomA(){
if(curfontsize>8){
document.getElementById('fontzoom').style.fontSize=(--curfontsize)+'pt';
document.getElementById('fontzoom').style.lineHeight=(--curlineheight)+'pt';
}
}
function fontZoomB(){
if(curfontsize<64){
document.getElementById('fontzoom').style.fontSize=(++curfontsize)+'pt';
document.getElementById('fontzoom').style.lineHeight=(++curlineheight)+'pt';
}
}
</SCRIPT>
<META content="MSHTML 6.00.2900.2180" name=GENERATOR></HEAD>
<BODY leftMargin=0 topMargin=0>
<DIV id=menuDiv
style="Z-INDEX: 1000; VISIBILITY: hidden; WIDTH: 1px; POSITION: absolute; HEIGHT: 1px; BACKGROUND-COLOR: #9cc5f8"></DIV><!-- ********网页顶部代码开始******** -->
<TABLE class=top_tdbgall style="WORD-BREAK: break-all" cellSpacing=0
cellPadding=0 width=760 align=center border=0>
<TBODY>
<TR>
<TD bgColor=#4f4f4f height=3></TD></TR>
<TR>
<TD class=top_Channel align=right width="100%"><FONT
color=red> | <A class=Channel
href="http://study.feloo.com/Index.html">网站首页</A> | <A
class=Channel2 href="http://study.feloo.com/computer/Index.html"
target=_self>电脑学习</A> | <A class=Channel
href="http://study.feloo.com/Article/Index.html"
target=_self>英语学堂</A> | <A class=Channel
href="http://study.feloo.com/lunwen/Index.html"
target=_self>论文中心</A> | <A class=Channel
href="http://study.feloo.com/exam/Index.html"
target=_self>试题资源</A> | <A class=Channel
href="http://study.feloo.com/jiaoan/Index.html"
target=_self>教案集锦</A> | <A class=Channel
href="http://study.feloo.com/kejian/Index.html"
target=_self>课件下载</A> | <A class=Channel
href="http://study.feloo.com/school/Index.html"
target=_self>高校联盟</A> | <A class=Channel
href="http://study.feloo.com/job/Index.html"
target=_self>求职创业</A> | <A class=Channel
href="http://study.feloo.com/fanben/Index.html"
target=_self>实用范本</A> | <A class=Channel
href="http://study.feloo.com/down"
target=_blank>软件下载</A> | </FONT></TD></TR>
<TR>
<TD bgColor=#4f4f4f height=1></TD></TR></TBODY></TABLE>
<TABLE class=top_tdbgall style="WORD-BREAK: break-all" cellSpacing=0
cellPadding=0 width=760 align=center border=0>
<TBODY>
<TR>
<TD align=middle height=72>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD align=middle width=180 height=72><A title=中国学习联盟
href="http://study.feloo.com/" target=_blank><IMG height=60
src="Linux环境进程间通信(一) 管道及有名管道.files/logo.gif" width=180
border=0></A></TD>
<TD align=middle width=*>
<SCRIPT src="Linux环境进程间通信(一) 管道及有名管道.files/banner.js"></SCRIPT>
</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<TABLE class=top_tdbgall style="WORD-BREAK: break-all" cellSpacing=0
cellPadding=0 width=760 align=center border=0>
<TBODY>
<TR>
<TD bgColor=#4f4f4f height=1></TD></TR>
<TR><!--banner广告显示代码-->
<TD align=middle>
<SCRIPT src="Linux环境进程间通信(一) 管道及有名管道.files/ban-wen.js"></SCRIPT>
</TD></TR>
<TR>
<TD bgColor=#4f4f4f height=1></TD></TR></TBODY></TABLE><!--导航代码开始-->
<TABLE class=top_Path style="WORD-BREAK: break-all" cellSpacing=0 cellPadding=0
width=760 align=center border=0>
<TBODY>
<TR>
<TD align=middle width="5%"><IMG height=25
src="Linux环境进程间通信(一) 管道及有名管道.files/ad_mqdhl.gif" width=40></TD>
<TD width="73%">您现在的位置: <A
href="http://study.feloo.com/">中国学习联盟</A> >> <A
href="http://study.feloo.com/computer/Index.html">电脑学习</A> >> <A
href="http://study.feloo.com/computer/pro/Index.html">程序设计</A> >> <A
href="http://study.feloo.com/computer/pro/vc/Index.html">VC语言</A> >> <A
href="http://study.feloo.com/computer/pro/vc/system/Index.html">系统类编程</A> >> 电脑文章正文</TD>
<TD align=middle width="22%"><IMG height=13
src="Linux环境进程间通信(一) 管道及有名管道.files/User_Login.gif" width=13
align=absMiddle> <A class=top_UserLogin
href="http://study.feloo.com/User/User_Login.asp" target=_blank>用户登录</A>
<IMG height=13 src="Linux环境进程间通信(一) 管道及有名管道.files/User_Reg.gif" width=13
align=absMiddle> <A class=top_UserLogin
href="http://study.feloo.com/Reg/User_Reg.asp" target=_blank>注册</A>
</TD></TR></TBODY></TABLE><!--导航代码结束--><!-- ********网页顶部代码结束******** --><!-- ********网页中部代码开始******** -->
<TABLE class=center_tdbgall style="WORD-BREAK: break-all" cellSpacing=0
cellPadding=0 width=760 align=center border=0>
<TBODY>
<TR>
<TD vAlign=top width=*><!--网页中部左栏文章内容代码开始-->
<TABLE style="WORD-BREAK: break-all" cellSpacing=0 cellPadding=0
width="100%" align=center border=0>
<TBODY>
<TR>
<TD class=main_title_282 vAlign=center width="3%"><IMG height=28
src="Linux环境进程间通信(一) 管道及有名管道.files/ad_dh.gif" width=29
align=absMiddle></TD>
<TD class=main_title_282 width="66%">Linux环境进程间通信(一): 管道及有名管道</TD>
<TD class=main_title_282
align=middle> <FONT
color=#009999>★★★★★</FONT></TD></TR></TBODY></TABLE>
<TABLE class=main_tdbg_575 style="WORD-BREAK: break-all" cellSpacing=0
cellPadding=0 width="100%" align=center border=0>
<TBODY>
<TR vAlign=center align=middle>
<TD class=main_ArticleTitle style="WORD-BREAK: break-all"
background="Linux环境进程间通信(一) 管道及有名管道.files/ad_dybg2.gif" colSpan=2
height=48>Linux环境进程间通信(一): 管道及有名管道</TD></TR>
<TR align=middle bgColor=#eeeeee>
<TD colSpan=2 height=24>作者:未知 文章来源:中国学习联盟 点击数:
<SCRIPT language=javascript
src="Linux环境进程间通信(一) 管道及有名管道.files/GetHits.htm"></SCRIPT>
更新时间:2005-6-9</TD></TR>
<TR>
<TD colSpan=2></TD></TR>
<TR align=right>
<TD colSpan=2 height=24>【字体:<A class=top_UserLogin
href="javascript:fontZoomA();">小</A> <A class=top_UserLogin
href="javascript:fontZoomB();">大</A>】【<A
href="http://study.feloo.com/computer/Comment.asp?ArticleID=39159"
target=_blank>发表评论</A>】【<A
href="http://study.feloo.com/User/User_Favorite.asp?Action=Add&ChannelID=25&InfoID=39159"
target=_blank>加入收藏</A>】【<A
href="http://study.feloo.com/computer/SendMail.asp?ArticleID=39159"
target=_blank>告诉好友</A>】【<A
href="http://study.feloo.com/computer/Print.asp?ArticleID=39159"
target=_blank>打印此文</A>】【<A
href="javascript:window.close();">关闭窗口</A>】 </TD></TR><!--文章标题下部广告代码开始-->
<TR>
<TD align=middle colSpan=2>
<SCRIPT src="Linux环境进程间通信(一) 管道及有名管道.files/wen-top.js"></SCRIPT>
</TD></TR><!--文章标题下部广告代码结束-->
<TR>
<TD background="Linux环境进程间通信(一) 管道及有名管道.files/ad_bx1.gif" colSpan=2
height=6></TD></TR>
<TR>
<TD colSpan=6></TD></TR>
<TR>
<TD id=fontzoom style="WORD-BREAK: break-all" vAlign=top colSpan=2
height=600><SPAN class=atitle2>管道及有名管道</SPAN>
<BLOCKQUOTE>在本系列<A
href="http://www-900.ibm.com/developerWorks/cn/linux/l-ipc/index.shtml">序</A>中作者概述了
linux
进程间通信的几种主要手段。其中管道和有名管道是最早的进程间通信机制之一,管道可用于具有亲缘关系进程间的通信,有名管道克服了管道没有名字的限制,因此,除具有管道所具有的功能外,它还允许无亲缘关系进程间的通信。
认清管道和有名管道的读写规则是在程序中应用它们的关键,本文在详细讨论了管道和有名管道的通信机制的基础上,用实例对其读写规则进行了程序验证,这样做有利于增强读者对读写规则的感性认识,同时也提供了应用范例。</BLOCKQUOTE>
<P><A name=1><SPAN class=atitle2>1、 管道概述及相关API应用</SPAN></A></P>
<P><SPAN class=atitle3>1.1 管道相关的关键概念</SPAN></P>
<P>管道是Linux支持的最初Unix IPC形式之一,具有以下特点:</P>
<UL class=n01>
<LI>管道是半双工的,数据只能向一个方向流动;需要双方通信时,需要建立起两个管道;
<LI>只能用于父子进程或者兄弟进程之间(具有亲缘关系的进程);
<LI>单独构成一种独立的文件系统:管道对于管道两端的进程而言,就是一个文件,但它不是普通的文件,它不属于某种文件系统,而是自立门户,单独构成一种文件系统,并且只存在与内存中。
<LI>数据的读出和写入:一个进程向管道中写的内容被管道另一端的进程读出。写入的内容每次都添加在管道缓冲区的末尾,并且每次都是从缓冲区的头部读出数据。
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -