pipe

What are all the differences between pipes and message queues?

走远了吗. 提交于 2019-12-31 20:15:11
问题 What are all the differences between pipes and message queues? Please explain both from vxworks & unix perspectives. I think pipes are unidirectional but message queues aren't. But don't pipes internally use message queues, then how come pipes are unidirectional but message queues are not? What are the other differences you can think of (from design or usage or other perspectives)? 回答1: Message Queues are: UNIDIRECTIONAL Fixed number of entries Each entry has a maximum size All the queue

Learning pipes, exec, fork, and trying to chain three processes together

倖福魔咒の 提交于 2019-12-31 04:05:09
问题 I'm learning to use pipes and following along with this code on pipes. The program makes two child processes using fork. The first child runs 'ls' command and outputs to pipe1. The second reads from pipe1 runs 'wc' and outputs to stdout. I'm just trying to add a third process in the middle that reads from pipe1 and outputs to pipe2. Basically what I'm trying to do ls | cat | wc -l What I'm trying to do: (ls)stdout -> pipe1 -> stdin(cat)stdout-> stdin(wc -l) -> stdout Nothing ever prints to

Best way to keep a pipe open after a remote close

匆匆过客 提交于 2019-12-31 03:12:11
问题 Using this tutorial i came up with the code below. My client is ran frequently. Its activated via clicks and possibly can be launched twice at the same moment in certain circumstance. I am worried one client may close while another client opens which causes the pipe to be closed in that slim few milliseconds. Whats the best way to keep the pipe open? static public void ThreadStartServer() { while (true) { using (NamedPipeServerStream pipeStream = new NamedPipeServerStream("mytestpipe")) {

How to copy files found with grep

六月ゝ 毕业季﹏ 提交于 2019-12-31 01:41:08
问题 I am running this command to find all my files that contain (with help of regex)"someStrings" in a tree directory. grep -lir '^beginString' ./ -exec cp -r {} /home/user/DestinationFolder \; It found files like this: FOLDER a.txt -->SUBFOLDER a.txt ---->SUBFOLDER a.txt I want to copy all files and folder, with the same schema, to the destination folder, but i don't know how to do it. It's important copy files and folder, because several files found has the same name and I need to keep it. 回答1:

How to pass command line parameters from a file

时光毁灭记忆、已成空白 提交于 2019-12-30 10:34:15
问题 I have a C program that reads command line arguments from argv. Is it possible to make a pipe to redirect the contents of a file as command line arguments to my program? Suppose I have a file arguments.dat with this content: 0 0.2 302 0 And I want my program to be called with: ./myprogram 0 0.2 302 0 I tried the following: cat arguments.dat | ./myprogram without success. 回答1: With most shells, you can insert the contents of a file into a command line with $(<filename) : ./myprogram $(

Pipe string to GNU Date for conversion - how to make it read from stdin?

冷暖自知 提交于 2019-12-30 07:58:09
问题 GNU Date lets you convert date strings like so: $ date +"%d %m %Y" -d "yesterday" 04 01 2012 Is it possible to pipe a date string to it for conversion? I've tried the obvious -d - like so: $ echo "yesterday" | date +"%d %m %Y" -d - but it prints today's date instead of yesterdays. Is it possible to pipe values to it or doesn't it support that? Thanks. 回答1: Yes. echo "yesterday" | xargs date +"%d %m %Y" -d 回答2: date -f tells it to do the same thing as -d except for every line in a file... you

fork(), pipe() and exec() process creation and communication

不羁的心 提交于 2019-12-30 06:49:11
问题 I have to write program that create process using pipe() . My first task is to write a parent process that generates four child processes using the fork() function. Once the fork() is successful, replace the child process with another process rover1, rover2, rover3, and rover4 , though all of them have the same code. The function of the processes is as follows. Each child process is initially given its own number. It receives a new number from the parent. Using the following formula it

redis之列表字典操作

泪湿孤枕 提交于 2019-12-30 04:21:01
Hash操作 hset(name,key,value) name对应的hash中设置一个键值对(不存在则创建,否则修改) 参数:name,redis中的name key,name对应的hash中的key value,name对应的hash中的value 注:hsetnx(name,key,value) ,当name对应的hash中不存在当前key时则创建 hmset(name,mapping) 在name对应的hash中批量设置键值对 参数:mapping,字典,如:{'k1':'v1','k2':'v2'} hget(name,key) 在name对应的hash中获取根据key获取value hmget(name,keys,*args) 在name对应的hash中获取多个key的值 参数:keys要获取key集合:['k1','k2','k3'] *args,要获取的key,如:k1,k2,k3 hgetall(name) 获取name对应hash的所有键值 hlen(name) 获取name对应的hash中键值对的个数 hkeys(name) 获取name对应的hash中多有的key的值 hvals(name) 获取name对应的hash中所有的value的值 hexists(name,key) 检查name对应的hash是否存在当前传入的key 返回值为数字(存在的个数)

NodeJS Copying File over a stream is very slow

独自空忆成欢 提交于 2019-12-30 00:36:10
问题 I am copying file with Node on an SSD under VMWare, but the performance is very low. The benchmark I have run to measure actual speed is as follows: $ hdparm -tT /dev/sda /dev/sda: Timing cached reads: 12004 MB in 1.99 seconds = 6025.64 MB/sec Timing buffered disk reads: 1370 MB in 3.00 seconds = 456.29 MB/sec However, the following Node code that copies file is very slow, evne teh consequent runs do not make it faster: var fs = require("fs"); fs.createReadStream("bigfile").pipe(fs

Why do I need to close fds when reading and writing to the pipe?

感情迁移 提交于 2019-12-29 18:04:52
问题 Here is an example to illustrate what I mean: #include <stdio.h> #include <unistd.h> #include <sys/types.h> int main(void) { int fd[2], nbytes; pid_t childpid; char string[] = "Hello, world!\n"; char readbuffer[80]; pipe(fd); if((childpid = fork()) == -1) { perror("fork"); exit(1); } if(childpid == 0) { /* Child process closes up input side of pipe */ close(fd[0]); /* Send "string" through the output side of pipe */ write(fd[1], string, (strlen(string)+1)); exit(0); } else { /* Parent process