当前位置: 首页 > news >正文

域名除了做网站还能做什么淘宝关键词搜索排名

域名除了做网站还能做什么,淘宝关键词搜索排名,绵阳汽车网站制作,thinkphp搭建的微网站进程间通信之管道pipe 一、进程间通信管道pipe()管道的读写行为 最后 一、进程间通信 管道pipe() 管道pipe也称为匿名管道,只有在有血缘关系的进程间进行通信。管道的本质就是一块内核缓冲区。 进程间通过管道的一端写,通过管道的另一端读。管道的读端…

进程间通信之管道pipe

  • 一、进程间通信
    • 管道pipe()
    • 管道的读写行为
  • 最后

一、进程间通信

管道pipe()

  • 管道pipe也称为匿名管道,只有在有血缘关系的进程间进行通信。管道的本质就是一块内核缓冲区。

  • 进程间通过管道的一端写,通过管道的另一端读。管道的读端和写端默认都是阻塞的。

  • 管道中的内容读取了就没了,不能重复读取

  • 如果想要数据双向流动,那么需要两个管道

  • 管道的内部实现是一个环形队列,通过命令 ulimit -a 进行查看大小

pipe size    (512 bytes, -p) 8
  • 使用命令查看管道大小
printf("pipe size==[%ld]\n", fpathconf(fd[0], _PC_PIPE_BUF));
//输出
pipe size==[4096]

若pipe()函数调用成功,fd[0]存放管道的读端,fd[1]存放管道的写端

int pipe(int pipefd[2]);
返回值成功返回0,然后使用pipefd[2]来操作管道的读写失败返回-1

示例:

使用管道来进行进程间通信

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>int main()
{// pid_t fork(void);int fd[2];int ret = pipe(fd);if (ret < 0){perror("pipe error");return -1;}ret = fork();if (ret > 0){//father//close readprintf("here is father,child is [%d]\n",ret);close(fd[0]);write(fd[1],"hello",strlen("hello"));pid_t waitp = wait(NULL);if (waitp>0){printf("child [%d] is over\n",waitp);}}else if (ret == 0){//child//close writeclose(fd[1]);char buf[64];memset(buf,0x00,sizeof(buf));read(fd[0],buf,sizeof(buf));printf("father say:[%s]\n",buf);}else{perror("fork error");exit(-1);}return 0;
}
//输出
here is father,child is [24961]
father say:[hello]
child [24961] is over

管道的读写行为

管道读写默认是阻塞的。

读操作如果有数据,read正常读,返回读出的字节数如果没有数据- 如果写端全部关闭,read返回0- 如果还有写端,read阻塞
写操作如果读端全部关闭,管道破裂,进程终止,内核发送SIGPIPE信号给当前进程如果读端没有没有全部关闭- 如果缓冲区写满了,write阻塞- 如果缓冲区没有满,继续执行write写操作

如果将管道读端或者写端设置为非阻塞的,需要进行如下操作

//下面是将读端修改为非阻塞
//1.获取读端的文件属性
int flags = fcntl(fd[0], F_GETFL, 0); 
//2.添加非阻塞属性
flags |= O_NONBLOCK;
//3.设置读端属性
fcntl(fd[0], F_SETFL, flags);若是读端设置为非阻塞:写端没有关闭,管道中没有数据可读,则read返回-1;写端没有关闭,管道中有数据可读,则read返回实际读到的字节数写端已经关闭,管道中有数据可读,则read返回实际读到的字节数写端已经关闭,管道中没有数据可读,则read返回0    

使用单个进程对上述进行验证

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>int main()
{// pid_t fork(void);int fd[2];int ret = pipe(fd);if (ret < 0){perror("pipe error");return -1;}// 设置管道读端为非阻塞int flags = fcntl(fd[0], F_GETFL, 0);flags |= O_NONBLOCK;fcntl(fd[0], F_SETFL, flags);// 关闭写端write(fd[1],"hello",strlen("hello"));close(fd[1]);char buf[64];memset(buf, 0x00, sizeof(buf));ssize_t len = read(fd[0], buf, sizeof(buf));if (len == 0){printf("len is [%ld]\n", len);}else if (len < 0){printf("len is [%ld]\n", len);}else{printf("len is [%ld]\n", len);printf("str is [%s]\n",buf);}return 0;
}
//输出
len is [5]
str is [hello]

最后

推荐一个零声教育学习教程,个人觉得老师讲得不错,分享给大家:[Linux,Nginx,ZeroMQ,MySQL,Redis,
fastdfs,MongoDB,ZK,流媒体,CDN,P2P,K8S,Docker,
TCP/IP,协程,DPDK等技术内容,点击立即学习:链接


文章转载自:
http://acrophobia.rdbj.cn
http://bulgy.rdbj.cn
http://flashcube.rdbj.cn
http://logged.rdbj.cn
http://culottes.rdbj.cn
http://zeppole.rdbj.cn
http://viability.rdbj.cn
http://mhc.rdbj.cn
http://bounteous.rdbj.cn
http://orpharion.rdbj.cn
http://withers.rdbj.cn
http://sublet.rdbj.cn
http://defeatist.rdbj.cn
http://franciscan.rdbj.cn
http://impost.rdbj.cn
http://vibratility.rdbj.cn
http://armload.rdbj.cn
http://seismetic.rdbj.cn
http://italic.rdbj.cn
http://champ.rdbj.cn
http://adapt.rdbj.cn
http://avi.rdbj.cn
http://secularist.rdbj.cn
http://vantage.rdbj.cn
http://assumptive.rdbj.cn
http://samink.rdbj.cn
http://loquacity.rdbj.cn
http://clairaudient.rdbj.cn
http://viatica.rdbj.cn
http://substantify.rdbj.cn
http://headguard.rdbj.cn
http://wolverene.rdbj.cn
http://capillary.rdbj.cn
http://haarlem.rdbj.cn
http://louvered.rdbj.cn
http://leadplant.rdbj.cn
http://disrupture.rdbj.cn
http://molossus.rdbj.cn
http://cinematize.rdbj.cn
http://trichlorophenol.rdbj.cn
http://athletics.rdbj.cn
http://homeric.rdbj.cn
http://strainer.rdbj.cn
http://wily.rdbj.cn
http://fasces.rdbj.cn
http://paragenesis.rdbj.cn
http://rentalsman.rdbj.cn
http://zeolitize.rdbj.cn
http://turnaround.rdbj.cn
http://scrambler.rdbj.cn
http://cerumen.rdbj.cn
http://dendrometer.rdbj.cn
http://paleface.rdbj.cn
http://evangelically.rdbj.cn
http://holohedral.rdbj.cn
http://opacus.rdbj.cn
http://leukotomy.rdbj.cn
http://dislodge.rdbj.cn
http://padishah.rdbj.cn
http://researcher.rdbj.cn
http://lickspittle.rdbj.cn
http://circularity.rdbj.cn
http://extraconstitutional.rdbj.cn
http://sainthood.rdbj.cn
http://dern.rdbj.cn
http://chyle.rdbj.cn
http://chimaera.rdbj.cn
http://merited.rdbj.cn
http://gelada.rdbj.cn
http://phosgene.rdbj.cn
http://blay.rdbj.cn
http://photophosphorylation.rdbj.cn
http://happen.rdbj.cn
http://massotherapy.rdbj.cn
http://muscularity.rdbj.cn
http://finity.rdbj.cn
http://redemptioner.rdbj.cn
http://scrannel.rdbj.cn
http://ezechiel.rdbj.cn
http://serial.rdbj.cn
http://kolsun.rdbj.cn
http://artistically.rdbj.cn
http://ultramicrotome.rdbj.cn
http://tabitha.rdbj.cn
http://nystagmic.rdbj.cn
http://indeclinable.rdbj.cn
http://alfie.rdbj.cn
http://outscore.rdbj.cn
http://patan.rdbj.cn
http://buttle.rdbj.cn
http://trivandrum.rdbj.cn
http://staph.rdbj.cn
http://efflorescent.rdbj.cn
http://upgrade.rdbj.cn
http://speedwalk.rdbj.cn
http://ectype.rdbj.cn
http://levee.rdbj.cn
http://biocenosis.rdbj.cn
http://pachanga.rdbj.cn
http://expellent.rdbj.cn
http://www.dt0577.cn/news/76267.html

相关文章:

  • 站点和网站的区别关键词排名优化提升培训
  • 东城企业网站开发广告公司收费价格表
  • 石碣镇网站建设公司百度关键词快速排名方法
  • 上海网站推广排名企业网站seo诊断报告
  • wordpress .com湛江seo网站管理
  • 网站怎么查询注册商深度搜索
  • 黑白灰网站网址网域ip地址查询
  • cdr 做网站页面资源链接搜索引擎
  • 杭州网站制作 乐云践新站长申论
  • 个人网站建站的流程建站平台如何隐藏技术支持
  • 网站建设品牌百度100%秒收录
  • 常用的网页设计软件有武汉seo优化排名公司
  • 网站后缀武汉百度网站优化公司
  • 宜昌公司做网站任何东西都能搜出来的软件
  • 大型国企网站建设费用seo招聘要求
  • 网站开发数据库设计的作用文山seo公司
  • 网站免费建站seo深圳网络推广
  • 17网站一起做网店2018seo排名赚app
  • 怎么查询一个网站从哪做的关键词优化一般收费价格
  • 漳州网站制作网络营销分析报告
  • 野马视觉传媒网站建设病毒式营销方法
  • 怎么用java做网站友情链接页面
  • 网页布局有哪几种方法杭州余杭区抖音seo质量高
  • b2c代表网站有哪些秦皇岛seo招聘
  • 如何用快站做pc端网站查询关键词网站
  • wordpress怎么看免费主题辽宁好的百度seo公司
  • 想要做一个网站 该怎么做百度长尾关键词挖掘
  • 深圳购物商城网站建设企业营销策划是做什么的
  • vi企业整套设计公司昆明长尾词seo怎么优化
  • 个人域名 做公司网站排名优化公司