pipe

IPC using pipes?

元气小坏坏 提交于 2020-01-07 07:59:08
问题 I m trying to implement a program using pipes where parent process accepts a string and passes it to child process. Need to be done with only single pipe. How does the pipe read & write accepts string. Here is my sample code! all! #include <iostream> #include <unistd.h> #include <stdio.h> #include <sys/types.h> using namespace std; int main() { int pid[2]; ssize_t fbytes; pid_t childpid; char str[20], rev[20]; char buf[20], red[20]; pipe(pid); if ((childpid = fork()) == -1) { perror("Fork");

C#: Read on subprocess stdout blocks until ANOTHER subprocess finishes?

谁都会走 提交于 2020-01-07 04:28:07
问题 Here is the C# code I'm using to launch a subprocess and monitor its output: using (process = new Process()) { process.StartInfo.FileName = executable; process.StartInfo.Arguments = args; process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardInput = true; process.StartInfo.CreateNoWindow = true; process.Start(); using (StreamReader sr = process.StandardOutput) { string line = null; while ((line = sr.ReadLine()) != null) {

XP+Windbg 双机调试 快速搭建

自古美人都是妖i 提交于 2020-01-06 16:28:02
XP+Windbg 双机调试 快速搭建 之前每次搭建都要网上搜教程,太麻烦了,直接写出重点步骤 【虚拟机部分】 打开虚拟机之后,进入C盘根目录,然后 点【工具】 【文件夹选项】 【查看】中 将 【隐藏受保护的操作系统文件】的钩钩去掉。 然后下面选择【显示所有文件和文件夹】,这样就会出现一个boot的文件,以TXT方法打开之后,直接在后面加上下面的红字部分 [boot loader] timeout=1 default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS [operating systems] multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect /noguiboot multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="MicrosoftWindows XP Professional" /noexecute=optin /fastdetect /debug/debugport =com1/baudrate=115200 然后将虚拟机电源切断,选择【虚拟机】 【设置】 (英文版好像是Command Setting) ,然后在默认的

Python equivalent to perl -pe?

纵饮孤独 提交于 2020-01-06 16:04:55
问题 I need to pick some numbers out of some text files. I can pick out the lines I need with grep, but didn't know how to extract the numbers from the lines. A colleague showed me how to do this from bash with perl: cat results.txt | perl -pe 's/.+(\d\.\d+)\.\n/\1 /' However, I usually code in Python, not Perl. So my question is, could I have used Python in the same way? I.e., could I have piped something from bash to Python and then gotten the result straight to stdout? ... if that makes sense.

Pipe multiple files (gz) into C program

谁说胖子不能爱 提交于 2020-01-06 13:12:49
问题 I've written a C program that works when I pipe data into my program using stdin like: gunzip -c IN.gz|./a.out If I want to run my program on a list of files I can do something like: for i `cat list.txt` do gunzip -c $i |./a.out done But this will start my program 'number of files' times. I'm interested in piping all the files into the same process run. Like doing for i `cat list.txt` do gunzip -c $i >>tmp done cat tmp |./a.out How can I do this? 回答1: There is no need for a shell loop: gzip

How do I read standard out into a bash variable without using a subshell or a named pipe

邮差的信 提交于 2020-01-06 10:32:26
问题 Inside a bash script I am piping the output of a curl request to tee and then duplicating the output to many subshells. At the end of each subshell I want to assign the result to a variable declared inside my script: #!/bin/bash token_secret="" token_value="" function extractTokenSecret() { sed -n 's/.*secret":"\([^"]*\)".*/\1/p' } function extractTokenValue() { sed -n 's/.*token":"\([^"]*\)".*/\1/p' } function createToken() { curl -v \ -X POST \ -s http://localhost:8080/token | tee >/dev

How to compile c++ code at runtime (like eval in Python)?

不羁岁月 提交于 2020-01-06 07:12:19
问题 I'm compiling some C++ code at runtime, which I'm then calling in a sort of plugin system, see also my other question. What I do is I create the source code, write it to a file, compile that file and write the output to another file. However, this process feels kinda ugly so I was hoping for some input. //Open a file std::ofstream fout("SOURCECODEPATH"); //Write actual function to file fout << "extern \"C\" void testFunc(float testArray[]) {\n" " testArray[0] = 1.0;\n" " testArray[1] = 2.0;\n

Read/writing on a pipe, accomplishing file copying in C

╄→尐↘猪︶ㄣ 提交于 2020-01-06 07:01:53
问题 I am trying to read from a file, write it to a pipe, and in a child process read from the pipe and write it to a new file. The program is passed two parameters: the name of the input file, and the name of the file to be copied to. This is a homework project, but I have spent hours online and have found only ways of making it more confusing. We were given two assignments, this and matrix multiplication with threads. I got the matrix multiplication with no problems, but this one, which should

Filter by checkbox in angular 5

女生的网名这么多〃 提交于 2020-01-06 05:21:06
问题 I am able to implement the filter on input field with the pipe. But I am not able to do so with checkbox filter. Below is my code for input filter. import { Pipe, PipeTransform } from '@angular/core'; @Pipe({ name: 'filter' }) export class FilterPipe implements PipeTransform { transform(users: any, searchTerm: any): any { // check if search term is undefined if (searchTerm === undefined) { return users; } // return updated users array return users.filter(function(user) { return user.name

Why can't I filter tail's output multiple times through pipes?

只愿长相守 提交于 2020-01-06 02:25:48
问题 Unexpectedly, this fails ( no output ; tried in sh , zsh , bash ): echo "foo\nplayed\nbar" > /tmp/t && tail -f /tmp/t | grep played | sed 's#pl#st#g' Note that two times grep also fails, indicating that it's quite irrelevant which commands are used: # echo -e "foo\nplayed\nbar" > /tmp/t && tail -f /tmp/t | grep played | grep played grep alone works: # echo -e "foo\nplayed\nbar" > /tmp/t && tail -f /tmp/t | grep played played sed alone works: # echo -e "foo\nplayed\nbar" > /tmp/t && tail -f