ipc

Waiting on a child process in perl

半世苍凉 提交于 2019-12-11 11:22:51
问题 I am having an issue with capturing the return status of the child process. below is a simplified version of my code. use Modern::Perl; use POSIX; use AnyEvent; my @jobs = (1, 7, 3, 9 , 4 , 2); my %pid; my %running; my $t = AE::timer 0, 5, sub{ while(scalar( keys %running < 3) && scalar (@jobs)){ my $job = shift @jobs; $running{$job}=1; $pid{$job} = run($job); } for(keys %running){ delete $running{$_} unless check($pid{$_},$_); } exit unless scalar keys %running; }; AnyEvent->condvar->recv;

Size of the Boost shared vector keeps fluctuating

雨燕双飞 提交于 2019-12-11 11:09:36
问题 I'm using a Boost based shared vector as IPC in my application. In the application where I'm trying to read the shared memory, the size of the memory, m_size, or vector->size , keeps fluctuating between 2 ( i.e. the number of vectors I'm sharing ),and 0. I've no idea why this is happening. Maybe it's a synchronization issue? But even if this is the case, the size of the memory should not come to 0, as it's just reading whatever is there in the memory. It may be invalid ( i.e. old data ), but

c - How to check EOF when read() on FIFO

折月煮酒 提交于 2019-12-11 10:52:02
问题 In a client-server program, need check EOF for read() on a FIFO ? Questions: Does EOF in FIFO return 0 , or -1 with errno set? Does the rule also apply to other IPC facilities? @Update I still found the result wield, so need to continue ask about it. Following are the source code: cs_fifo.h: // fifo header #ifndef _CS_FIFO #define _CS_FIFO #define CLIENT_DATA_SIZE 2 #define SERVER_DATA_SIZE 10 #define SERVER_FIFO_PATH "/tmp/server_fifo" #define CLIENT_COUNT 3 #endif fifo_server.c: // client -

Why does reading from pipe block the process?

∥☆過路亽.° 提交于 2019-12-11 10:09:53
问题 I have two processes ( both .NET Framework applications) and i am trying to communicate using Named Pipes The client connects to the pipe , but when it tries to ReadAsync the message sent by the server, it starts waiting indifinetly , even though the server has already sent a message !! What surprises me is that if i close the Server app the Client finally continues to the next line of code (after the ReadAsync line), having read 0 bytes. Is there anything i must to on the server after

How to change the fd associated with the stdin file descriptor?

匆匆过客 提交于 2019-12-11 10:00:30
问题 I want to associate pipe's write fd to the stdout. int pfds[2]; char buf[30]; if (pipe(pfds) == -1) { perror("pipe"); exit(1); } I want to associate pfd[1] to the stdout of the process. I understand, we can use freopen to redirect stdout to the file. I was hoping to get something similar to this. 回答1: dup2(2) is probably the easiest way: dup2(pfds[1], STDOUT_FILENO); 来源: https://stackoverflow.com/questions/18497401/how-to-change-the-fd-associated-with-the-stdin-file-descriptor

What is the fastest and easiest way to communicate between 2 processes in C#?

牧云@^-^@ 提交于 2019-12-11 09:00:49
问题 From my main c# app, I start many slave process with Process.Start method. (on the same PC) Just before starting those slave process, I serialize some data (I have serialized class) in XML files which are passed in the arguments of Process class. In each slave process, those data are deserialized and a computation is done. A new serialization is done to XML in order to send result to the main process. My apps works but the performance are very bad. The time of serialization/deserialization

Named pipe in windows, difference between FILE_FLAG_OVERLAPPED and PIPE_NOWAIT

余生颓废 提交于 2019-12-11 08:28:12
问题 I am using named pipe in windows and confused about the difference between FILE_FLAG_OVERLAPPED and PIPE_NOWAIT which are parameters set in CreateNamedPipe ,I set parameters like this. HANDLE hPipe = CreateNamedPipe( lpszPipename, // pipe name PIPE_ACCESS_DUPLEX | // read/write access FILE_FLAG_OVERLAPPED, // overlapped mode PIPE_TYPE_MESSAGE | // message-type pipe PIPE_READMODE_MESSAGE | // message read mode PIPE_WAIT, // blocking mode PIPE_UNLIMITED_INSTANCES, // unlimited instances BUFSIZE

JavaScript: How to stringify a class, after calling new

浪子不回头ぞ 提交于 2019-12-11 08:14:13
问题 TL;DR: I need to inject some JavaScript into a BrowserView in Electron using executeJavaScript. This code needs to be class. How can I stringify the class? I found out that you can stringify functions using + . const fn = function() { console.log('Hello'); }; const functionToText = '' + fn; console.log(functionToText); // function() { // console.log('Hello'); // } */ But my problem is, how can you stringify classes? I need the string version of the following object created from the class with

Intra-Process Communication in Objective C

走远了吗. 提交于 2019-12-11 08:09:49
问题 I want to know how can a child thread talk to parent thread in Objective C. I am spawning a thread from my main thread and want to intimate main thread about some action and keep continuing. How to achieve this? 回答1: If you post a NSNotification in the child thread, the receiver will receive the notification and execute under the same thread as the sender. The apple document said that and marked as a note. The information between threads can be transfered by a shared memory, ex: a struct,

Data exchange between daemon and launch agent

无人久伴 提交于 2019-12-11 07:44:40
问题 Mac OS X Snow Leopard and Lion. I have a daemon (which runs from root) and launch agent which runs from current user. How can daemon request data (or send command) to launch agent? 回答1: If you want to achieve simple IPC between the daemon and agent, refer to my answer here : OS X - Communication between launch daemon and launch agent. Make sure to set up this socket-based communication on separate threads, so as not to interrupt the flow of your program. 来源: https://stackoverflow.com