pipe

C system calls pipe, fork, and execl

偶尔善良 提交于 2019-12-24 13:55:02
问题 I fork()'d a child process and created pipes between them and am able to send argument argv[1] to the child. I want the child to take that filename provided from argv[1] and perform an execl("/bin/cat","cat",(char *) 0); How do I route the filename piped to the child to the execl? Enclose is my code for clearity : int main(int argc, char ** argv){ int fds[2]; char buffer[100]; int status; if(pipe(fds) == -1){ perror("pipe creation failed"); exit(EXIT_FAILURE); } switch (fork()){ case 0:/

NodeJs: slow req.pipe

时间秒杀一切 提交于 2019-12-24 13:50:26
问题 I've discovered that the server implementation of tus (https://tus.io) for nodejs (https://github.com/tus/tus-node-server) is really slow in comparison with the go implementation (https://github.com/tus/tusd). Here you may find a comparison between the different implementations (running locally, same machine, same input) nodejs: [2019-01-31 16:22:45,578] INFO Uploading 52428800 bytes chunk from offset: 104857600 [2019-01-31 16:22:47,329] INFO Total bytes sent: 157286400 (kb/s: 29930) go:

how to redirect the output of serial console (e.g. /dev/ttyS0) to a buffer or file

你离开我真会死。 提交于 2019-12-24 12:19:03
问题 Is it possible to pipe serial console output to a file or a buffer or some virtual or pseudo device (in /dev)? The Kernel command line has in startup at this point "console=null,115200". (Normally it has "console=ttyS0,115200" - my requirement is: if "console=null,115200", should the output go to some other place than ttyS0, e.g. a virtual or pseudo device or to a file/buffer) Maybe somebody know if there is good solution available? Thanks a lot in advance! 回答1: There are two ways that I am

进程间通信-管道

拜拜、爱过 提交于 2019-12-24 12:06:13
转自: 0giant 管道允许在进程之间按先进先出的方式传送数据,是进程间通信的一种常见方式。 管道是Linux 支持的最初Unix IPC形式之一,具有以下特点: 1) 管道是 半双工的 ,数据只能向一个方向流动; 需要双方通信时,需要建立起两个管道 ; 2) 匿名管道只能用于父子进程或者兄弟进程之间(具有亲缘关系的进程); 3) 单独构成一种独立的文件系统:管道对于管道两端的进程而言,就是一个文件,但它不是普通的文件,它不属于某种文件系统,而是自立门户,单独构成一种文件系统,并且只存在与内存中。 管道分为pipe(无名管道)和fifo(命名管道)两种,除了建立、打开、删除的方式不同外,这两种管道几乎是一样的。他们都是通过内核缓冲区实现数据传输。 pipe用于相关进程之间的通信,例如父进程和子进程,它通过pipe()系统调用来创建并打开,当最后一个使用它的进程关闭对他的引用时,pipe将自动撤销。 FIFO即命名管道, 在磁盘上有对应的节点,但没有数据块 ——换言之,只是拥有一个名字和相应的访问权限,通过mknode()系统调用或者mkfifo()函数来建立的。一旦建立,任何进程都可以通过文件名将其打开和进行读写,而不局限于父子进程,当然前提是进程对FIFO有适当的访问权。当不再被进程使用时,FIFO在内存中释放,但磁盘节点仍然存在。 管道的实质是一个内核缓冲区

Go exec.Command() - run command which contains pipe

不羁岁月 提交于 2019-12-24 11:37:12
问题 The following works and prints the command output: out, err := exec.Command("ps", "cax").Output() but this one fails (with exit status 1): out, err := exec.Command("ps", "cax | grep myapp").Output() Any suggestions? 回答1: You could do: out, err := exec.Command("bash", "-c", "ps cax | grep myapp").Output() 回答2: Passing everything to bash works, but here's a more idiomatic way of doing it. package main import ( "fmt" "os/exec" ) func main() { grep := exec.Command("grep", "redis") ps := exec

finding matches inside pipes using java regexp

∥☆過路亽.° 提交于 2019-12-24 11:04:55
问题 how do you get the contents of the string inside the pipe? |qwe|asd|zxc| how can I get qwe asd zxc i tried this "\\|{1,}(\\w*)\\|{1,}" and it don't seem to work i also tried this "\\|{1,}[\\w*]\\|{1,}" it only returns qwe though 回答1: if String line="|qwe|asd|zxc|"; then use string[] fields = line.split("\\|"); to get array of all your result.. 回答2: Regex is not needed for this but if you insist on using regexes: Pattern p = Pattern.compile("\\|?(\\w+)\\|"); Matcher m = p.matcher("|qwe|asd|zxc

non-blocking read of a pipe while doing other things

﹥>﹥吖頭↗ 提交于 2019-12-24 09:39:38
问题 As a follow-up to process hangs when writing large data to pipe, I need to implement a way for a parent process to read from a pipe being written to by its child process, while doing other things until the child has completed. More specifically, the parent is returning a response to a client over HTTP. The response consists of the string <PING/> , followed by the string <DONE/> when it is done pinging, followed by the actual content. This is being done to keep the connection alive until the

Using pipes in C for parent-child IPC makes program block

﹥>﹥吖頭↗ 提交于 2019-12-24 08:59:29
问题 I am writing a server which fork()'s off a child process when it accepts a socket connection. As the child communicates with a client, it must send some of that information back to the parent. I am using a pipe to accomplish this. The problem is that when I try to do the parent-child IPC, the parent blocks when reading input from the child. Which means that, even though the children are running concurrently, they can only be processed one-at-a-time because they are all waiting for the parent.

Using named pipes to create a 'loop'

独自空忆成欢 提交于 2019-12-24 08:03:58
问题 I'm very new to shell scripting and I am trying to get to grips with piping. I could be heading in completely the wrong direction here... What I have is a shell script that contains a simple while true loop, within this loop I am getting netcat to listen on a specified port and piping input to a binary file that is awaiting for commands through stdin. This is Script-A I have a second shell script that accepts input as arguments, it then echos those arguments to the port that netcat is

how 2 c++ programs call each other's class/functions on same linux box?

落花浮王杯 提交于 2019-12-24 07:29:27
问题 I'm brand new to c++, so my vocab's probably off. I currently make 100% ajax sites but want to work in websockets to autoupdate relevant clients. I'm using fastcgi++ and websocket++. I'd like to serve all data via the websocket but update the database via ajax calls. My problem comes in when I want to have the ajax page trigger the websocket. I've read about sockets, fifo, and pipes, but I'm not sure which one is ideal for this situation. For two c++ programs, one ajax & one websocket, on the