shell 管道两端的程序,并不是左边的程序先启动 - yanbin's Blog
shell 管道两端的程序,并不是左边的程序先启动
yanbin
posted @ 2015年3月15日 23:05
in Linux-使用
, 1636 阅读
$ ps aux | grep "demo"
这条命令中的 ps 先启动,会导致程序异常退出。
因为写一个没有读端的管道,引发 SIGPIPE 信号,SIGPIPE 信号默认行为是终止程序的执行。
管道的创建者(shell) 先创建管道,启动 read 管道的程序 (grep), 再启动 write 管道的程序(ps aux).
读一个没有写端的管道会阻塞,grep 可以接受阻塞。
$ ps aux | grep "demo" | grep -v "grep"
这样的命令相当于: (ps aux | grep "demo") | grep -v "grep".
2018年3月26日 17:12
This is also a very good post which I really enjoyed reading.
2018年6月28日 16:54
an excellent runner on the android device that has conquered millions of players from all over the world. In this game you .
2019年5月13日 22:26
Wonderful site it is great it will give you free assistance.
2023年1月08日 13:42
This is because the programs at the ends of the pipeline are not started first. The program on the left is the one that starts the pipeline, and the program on the right is the one that finishes it. THC Vs CBD In between, the programs are started in the order they appear in the pipeline.
2024年1月09日 14:24
JNANABHUMI AP provides all latest educational updates and many more. The main concept or our aim behind this website has been the will to provide resources full information on each topic which can be accessed through Internet. To ensure that every readers get’s what important and worthy about the topic they search and link to hear from us. jnanabhumiap.in Jnanabhumi AP is a startup by passionate webmasters and bloggers who have passion to provide engaging content which is accurate, interesting and worthy to read. We are mope like a web community where you can find different information’s, resources, topics on day to day incidents or news. We provide you the finest of web content on each and every topics possible with help of editorial and content team.