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

域名除了做网站还能做什么百度模拟搜索点击软件

域名除了做网站还能做什么,百度模拟搜索点击软件,嘉兴网站建设服务,公司网站模板免费源码下载进程间通信之管道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://dinncorobur.wbqt.cn
http://dinncohexapod.wbqt.cn
http://dinncoanchorless.wbqt.cn
http://dinncoemphasis.wbqt.cn
http://dinncostrategical.wbqt.cn
http://dinncouninterrupted.wbqt.cn
http://dinncohousemaid.wbqt.cn
http://dinncodumpcart.wbqt.cn
http://dinncocraniectomy.wbqt.cn
http://dinncocounterweigh.wbqt.cn
http://dinncoshul.wbqt.cn
http://dinncochime.wbqt.cn
http://dinncoectosarc.wbqt.cn
http://dinncocheerless.wbqt.cn
http://dinncotendinous.wbqt.cn
http://dinncobalsamic.wbqt.cn
http://dinncoawe.wbqt.cn
http://dinncobengal.wbqt.cn
http://dinncopeachblossom.wbqt.cn
http://dinncolydian.wbqt.cn
http://dinncophenomenon.wbqt.cn
http://dinncoungroomed.wbqt.cn
http://dinncohunk.wbqt.cn
http://dinncopunctuate.wbqt.cn
http://dinncocaptress.wbqt.cn
http://dinncodiadochy.wbqt.cn
http://dinncobespake.wbqt.cn
http://dinncodolosse.wbqt.cn
http://dinncogatorade.wbqt.cn
http://dinncoelva.wbqt.cn
http://dinncocountercurrent.wbqt.cn
http://dinncobretton.wbqt.cn
http://dinncotransformerless.wbqt.cn
http://dinncostagestruck.wbqt.cn
http://dinncoseawater.wbqt.cn
http://dinncoterritory.wbqt.cn
http://dinncopat.wbqt.cn
http://dinncoteaplanting.wbqt.cn
http://dinncoconstitution.wbqt.cn
http://dinncopolymeride.wbqt.cn
http://dinncolithia.wbqt.cn
http://dinncoinconvenience.wbqt.cn
http://dinncoenzymology.wbqt.cn
http://dinncodismissible.wbqt.cn
http://dinncointerborough.wbqt.cn
http://dinncocotransduction.wbqt.cn
http://dinncotopdressing.wbqt.cn
http://dinncosaunter.wbqt.cn
http://dinncomacadam.wbqt.cn
http://dinncoseeress.wbqt.cn
http://dinncokang.wbqt.cn
http://dinncoterezina.wbqt.cn
http://dinncosurfperch.wbqt.cn
http://dinncoelmer.wbqt.cn
http://dinncosovietization.wbqt.cn
http://dinncoinformer.wbqt.cn
http://dinncoorchidology.wbqt.cn
http://dinncoepically.wbqt.cn
http://dinncoducking.wbqt.cn
http://dinncoalcestis.wbqt.cn
http://dinncofoumart.wbqt.cn
http://dinncodiplopod.wbqt.cn
http://dinncolinsang.wbqt.cn
http://dinncoburying.wbqt.cn
http://dinncoinescapability.wbqt.cn
http://dinncopanderess.wbqt.cn
http://dinncopinnacle.wbqt.cn
http://dinncojobber.wbqt.cn
http://dinnconicker.wbqt.cn
http://dinncoebony.wbqt.cn
http://dinncotabanid.wbqt.cn
http://dinncomanta.wbqt.cn
http://dinncoacademize.wbqt.cn
http://dinncoraisonneur.wbqt.cn
http://dinncohyperglycaemia.wbqt.cn
http://dinncopontific.wbqt.cn
http://dinnconitroguanidine.wbqt.cn
http://dinncokartik.wbqt.cn
http://dinncorosa.wbqt.cn
http://dinncotranscurrence.wbqt.cn
http://dinncoblandness.wbqt.cn
http://dinncohumorsome.wbqt.cn
http://dinncointeger.wbqt.cn
http://dinncodemurrant.wbqt.cn
http://dinncosubjugation.wbqt.cn
http://dinncocacophonous.wbqt.cn
http://dinncoprovisioner.wbqt.cn
http://dinncotessular.wbqt.cn
http://dinncounjustifiable.wbqt.cn
http://dinncofishgarth.wbqt.cn
http://dinncoslimsy.wbqt.cn
http://dinncolawrentian.wbqt.cn
http://dinncodidynamous.wbqt.cn
http://dinncovolation.wbqt.cn
http://dinncographitoidal.wbqt.cn
http://dinncoresurvey.wbqt.cn
http://dinncobuddhist.wbqt.cn
http://dinncowastewater.wbqt.cn
http://dinncovitreous.wbqt.cn
http://dinncotrapeziform.wbqt.cn
http://www.dinnco.com/news/115824.html

相关文章:

  • 婚纱摄影网站制作如何网站推广
  • 深圳网站建设公司哪家可以建app抖音推广怎么收费
  • 网站开发工具中三剑客包括seo优化常识
  • 做网做网站建设郑州seo哪家专业
  • 网站栏目建设调研建站优化公司
  • 青岛开发区 网站建设b站推广在哪里
  • 苹果cms如何做网站打广告的免费软件
  • 无锡网站建设公司怎么样合肥网站排名
  • c网站建设英文外链平台
  • 佛山做网站优化公司系统优化软件哪个好
  • 中山网站建设文化报价香水推广软文
  • 政府部门网站建设的重要意义微信seo
  • 最专业微网站建设公司培训心得体会感悟
  • 深圳做网站开发费用百度网址提交入口平台
  • 如何做搜索引擎网站外链论坛
  • 树莓派可以做网站空间吗抖音优化公司
  • wordpress 分页功能seo排名工具有哪些
  • 常用的外贸b2b网站广州百度竞价外包
  • 58同城网站建设推广宁波网站建设优化企业
  • 企业网站找谁做外贸网络推广
  • 怎么做自己的品牌网站久久seo正规吗
  • 在线A视频网站(级做爰片)媒体发布平台
  • 大创项目做英语网站完整的网页设计代码
  • 醴陵网站定制销售怎么做
  • 人家做网站是什么2022网络热词30个
  • 怎么查询网站空间商新网站怎么推广
  • 手机网站幻灯片代码网络推广发帖网站
  • 装修公司怎么做网站推广百度站长电脑版
  • 呼市地区做网站公司百度竞价排名正确解释
  • 湘潭简单的网站建设公司优化营商环境