pipe

Calculations in childs using pipes

为君一笑 提交于 2020-01-05 09:28:08
问题 My task is a. A parent and two childs b. Parent take data from the user c. Send to a child for addition and subtraction. d. Again take input from user and send to another child for multiplication and division. e. First child process creates another child C3. f. Both the childs send result to the child process C3 to show output. g. Parent process after completion of each child process task kill the process. I've write the following code but i don't know where I'm doing wrong, I tried to debug

Calculations in childs using pipes

允我心安 提交于 2020-01-05 09:26:27
问题 My task is a. A parent and two childs b. Parent take data from the user c. Send to a child for addition and subtraction. d. Again take input from user and send to another child for multiplication and division. e. First child process creates another child C3. f. Both the childs send result to the child process C3 to show output. g. Parent process after completion of each child process task kill the process. I've write the following code but i don't know where I'm doing wrong, I tried to debug

Infinite pipe insanity

落花浮王杯 提交于 2020-01-05 08:58:38
问题 I'm trying to create an infinte set of pipes to traverse from the left process to the right process. I'm using a fd to keep the previous out fd and input it to the new process. Can anyone see where I'm going wrong. It should be pretty simple to see at this point. I documented well. //Keep the previous out fd for the in of the subsequent process int prev_out_fd; for (x = 0; x < prog_count; ++x) { //Create a pipe for both processes to share int pipefd[2]; if (x != prog_count -1) { pipe(pipefd);

boost process running() and exit_code() thread safety

ぐ巨炮叔叔 提交于 2020-01-05 08:55:11
问题 I am using boost::process::child and boost::process::async_pipe to start an application and read asynchronously (through the means of boost::asio ) everything that app outputs on screen whenever this happens. I want to check also if the application is alive by using child::running() method; if not running I'd like to read the exit code using child::exit_code . This is very useful ESPECIALLY as it is a way to be notified about an application crashing or exiting unexpectedly (I could not find a

Matlab read from fifo with fopen timeout

人走茶凉 提交于 2020-01-05 05:52:30
问题 I'm working with named pipes (fifo) to communicate between python and MATLAB. The MATLAB code to read from the pipe is functional but it hangs if nothing has been written to the fifo. I would prefer it would gracefully timeout when no data is available. If the pipe exists (in bash): $ mkfifo pipe_read but has no data the MATLAB open command: >> fid = fopen('pipe_read', 'r'); hangs until data is available: $ echo "test data" >> pipe_read Rather than blocking forever I would like fopen to

pipe foreach loop CSV PowerShell

左心房为你撑大大i 提交于 2020-01-05 05:46:04
问题 I've written a script but cannot get it to export to CSV or output in any way. PowerShell does not like foreach loops and exporting. For each "folderpath/filename" in the .txt file it checks to see if the file is still there and outputs true or false + folderpath/file name. Script works fine, just cannot get the thing to export to CSV. Any ideas what I'm doing wrong? foreach ($WantFile in Get-Content "C:\scripts\folderpaths.txt") { $FileExists = Test-Path $WantFile if ($FileExists -eq $True)

Why my named pipe input command line just hangs when it is called?

送分小仙女□ 提交于 2020-01-05 05:29:07
问题 Why my named pipe input command line just hangs when it is called? Based on the answers: Writing to stdin of background process Accessing bash command line args $@ vs $* Send command to a background process Can I redirect output to a log file and background a process at the same time? I wrote two shell scripts to communicate with my game server. And worked the first time I did it. Since it them they do not work anymore. Every time I do ./send.sh commands the command line hangs until I hit

Linux下进程中的通信(上)

给你一囗甜甜゛ 提交于 2020-01-04 19:23:31
一.进程通信的概念 为什么要进程通信? 进程通信:顾名思义,应该是两个进程间进行通信。 进程之间具有独立性,每个进程都有自己的虚拟地址空间,进程A不知道进程B的虚拟地址空间的数据内容(类似于一个人不知道另一个人脑子里在想啥) 二.进程间通信方式的分类 进程间通信方式的共同点: 进程间需要“介质”—两个进程都能访问到的公共资源。 常见的通信方式: 文件(最简单的方法) 假如用vim打开一个test.c文件,这时候会自动产生一个以文件名结尾的.swap文件,用于保存数据。 当正常关闭时,此文件会被删除。当文件非正常关闭时(比如编辑代码时突然断网),如果此时再次通过vim打开该文件,就会提示存在.swap文件,此时你可以通过它来恢复文件:vim -r filename.c 恢复以后把.swap文件删掉,就不会再出现一堆提示了。所以该文件存在就是为了进行进程中的通信。 管道 1.管道定义:一个进程连接到另一个进程的数据流。 ps aux | grep test ,将前一个进程(ps)的输出作为后一个进程(grep)的输入两进程间通过管道进行通信。 ps aux | -l :wc指word count,-l指行数,将ps aux进程的标准输出作为wc -l的标准输入。 2.管道分类 匿名管道和命名管道。 匿名管道 管道是在内核中的一块内存(构成了一个队列)

Background process redirect to COPROC

喜夏-厌秋 提交于 2020-01-04 11:04:28
问题 In the following test script I run an elementary coprocess to which the echo built-in, run in background, attaches its standard-output: #!/bin/bash # TEST 1 coproc /bin/sleep 100 echo >&${COPROC[1]} & The script always fails, for no apparent reason, giving the output: ./test.sh: line 4: ${COPROC[1]}: Bad file descriptor I wonder if the correct syntax should be rather this one (ampersand moved before redirection): #!/bin/bash # TEST 2 coproc /bin/sleep 100 echo & >&${COPROC[1]} This second

python 进程间通信Queue/Pipe(42)

人盡茶涼 提交于 2020-01-04 09:26:50
目录 一.前言 使用Queue线程间通信: 使用Queue进程间通信,适用于多个进程之间通信: 使用Pipe进程间通信,适用于两个进程之间通信(一对一): 二.python进程间通信Queue/Pipe使用 1.使用Queue进程间通信,Queue包含两个方法: 2.使用Pipe进程间通信 三.测试queue.Queue来完成进程间通信能否成功? 猜你喜欢: 一.前言 1.在前一篇文章 python进程Process与线程threading区别 中讲到线程threading共享内存地址,进程与进程Peocess之间相互独立,互不影响(相当于深拷贝); 2.在线程间通信的时候可以使用Queue模块完成,进程间通信也可以通过Queue完成,但是此Queue并非线程的Queue,进程间通信Queue是将数据 pickle 后传给另一个进程的 Queue, 用于父进程与子进程之间的通信或同一父进程的子进程之间通信; 使用Queue线程间通信: #导入线程相关模块 import threading import queue q = queue.Queue() 使用Queue进程间通信,适用于多个进程之间通信: # 导入进程相关模块 from multiprocessing import Process from multiprocessing import Queue q = Queue()