ipc

Communicating between a parent and its children

倾然丶 夕夏残阳落幕 提交于 2019-12-06 13:37:21
Newbie question: On Unix, in a program with a parent and some children: - How can the parent alert the children efficiently to do some work.. ? - Or how can the children wait for parent signal to start doing some work? EDIT: This program tries to do a complex computation in parallel, I have already used shared memory as a common workspaces for all children to update results and for data transfer. What I need now is the parent say "start" efficiently to all its children...(called many times) Thanks Your ipc tag says it all. You need to look into inter-process communuication: Shared memory.

Can't do blocking read from named pipe (FIFO) in Linux

泪湿孤枕 提交于 2019-12-06 13:37:10
It is very weird that I can't seem to make this work. This is my architecture: I have a named pipe which will communicate between a always-running root reader process and multiple application writer processes. The reader process has to be blocking while the writers are nonblocking . Therefore this is what I do in the reader process which will run with root privilege. reader.c #define PIPE_ID "/dev/shm/mypipe" // This function configures named pipe void configure_pipe() { // So that others can write umask(0000); if(mkfifo(PIPE_ID, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH | S_IWGRP | S_IWOTH) != 0)

Running bash using posix instead of fork/execv

爷,独闯天下 提交于 2019-12-06 12:58:37
I have a CLI, one of the commands is entering into Linux bash shell. This is the code which does it using fork & execv: if ((pid = fork()) < 0) { syslog_debug(LOG_ERR, "Could not fork"); } if (pid == 0) { /* In child, open the child's side of the tty. */ int i; for(i = 0; i <= maxfd; i++) { close(i); } /* make new process group */ setsid(); if ((fd[0] = open(tty_name, O_RDWR /*| O_NOCTTY*/)) < 0) { syslog_debug(LOG_ERR, "Could not open tty"); exit(1); } fd[1] = dup(0); fd[2] = dup(0); /* exec shell, with correct argv and env */ execv("/bin/sh", (char *const *)argv_init); exit(1); } I want to

simple IPC mechanism for C#/WPF application to implement app CLI

て烟熏妆下的殇ゞ 提交于 2019-12-06 12:05:23
问题 So I've been reading lots about interprocess communication on .Net. Named pipes, remoting. It all seems great but possibly overkill for what I need to do. I want to add a command line interface to my WPF application, so I need a simple IPC mechanism to send the string from one process to the already running app. What does SO recommend for doing so? 回答1: NamedPipeClientStream and NamedPipeServerStream are pretty simple. Here's a pretty simple example where IPC is used to pass command line

Maximum limit on size of data in IPC using sockets in unix

走远了吗. 提交于 2019-12-06 12:01:27
问题 I am using AF_UNIX,SOCK_STREAM socket for IPC between 2 different processes. The client is sending data over the socket which the server picks up and processes. The size of each block of data that the client writes to the socket is roughly 13 kilobytes using the following command: Send Command in client : send(s, txPackDisp, sizeof(float)*PACKET_LENGTH, 0); However, when I receive the data on the server using the following command : Receive command in server : recv(s, bfoData, PACKET_LENGTH

communication between 2 browser windows in electron

假装没事ソ 提交于 2019-12-06 11:24:32
I need to build an app that will span across multiple monitor screens, something like this: Electron suports multiple windows but how to comunicate between them? The main thing to remember is that in Electron, interProcess communication is done by ipcMain (in the main process) and ipcRenderer(in all the created windows). Like below: From what i've seen in the GitHub comments - direct communication between the Renderer instances is not allowed. Everything must pass trough the mainProcess. the code: mainProcess.js: function createWindow1 () { window1 = new BrowserWindow({width: 800,height: 600})

消息通讯(IPC)

冷暖自知 提交于 2019-12-06 11:02:05
在PHP中使用共享内存段 在不同的处理进程之间使用共享内存是一个实现不同进程之间相互通讯的好方法。如果你在一个进程中向所共享的内存写入一段信息,那么所有其他的进程也可以看 到这段被写入的数据。非常方便。 在PHP中有了共享内存的帮助,你可以实现不同进程在运行同一段PHP脚本时返回不同的结果。或实现对PHP同时运行数量 的实时查询等等。共享内存允许两个或者多个进程共享一给定的存储区。因为数据不需要在*户机和*务器之间复制,所以这是最快的一种IPC。使用共享内存的唯一窍门是多个进程对一给定存储区的同步存取。 如何建立一个共享内存段呢?下面的代码可以帮你建立共享内存。$shm_id = shmop_open($key, $mode, $perm, $size);注意,每个共享内存段都有一个唯一的ID, 在PHP中,shmop_open会把建立好的共享内存段的ID返回,这里我们用$shm_id记录它。而$key是一个我们逻辑上表示共享内存段的 Key值。不同进程只要选择同一个Key id就可以共享同一段存储段。习惯上我们用一个串(类似文件名一样的东西)的散列值作为key id. $mode指明了共享内存段的使用方式。 这里由于是新建,因此值为’c’ –取create之意。如果你是访问已经建立过的共享内存那么请用’a’,-- 取access之意。$perm参数定义了访问的权限,8进制

one-to-many IPC

妖精的绣舞 提交于 2019-12-06 09:29:08
问题 I'm looking for an ipc mechanism which would allow high throughput of data updates from one process to many (thousands). The 'server' process would be responsible for updating a data structure at a high frequency. Upon update, I'd like to notify the 'client' processes of the update, and allow those processes to read the new data. Under a Linux or FreeBSD environment, what would be a good way to go about this? 回答1: I would recommend using ZeroMQ. It's a fast, lightweight, cross-platform, cross

IPC via mmap'ed file: should atomics and/or volatile be used?

拥有回忆 提交于 2019-12-06 08:27:28
I use a mmap'ed file to share data between processes. The code is like this: struct Shared { int Data; }; int file = open("file.dat", O_RDWR); Shared* shared = static_cast<Shared*>( mmap(0, sizeof(Shared), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, file, 0)); shared->Data++; The questions are: Should I use volatile qualifier ( volatile int Data )? Should I use atomic operations on the shared data ( __sync_fetch_and_add(&(shared->Data), 1) )? For future reference: Volatile: Almost Useless for Multi-Threaded Programming . You should not use volatile when changing an integer from more

Is there a way to send messages from C#.NET assembly(ActiveX) to VB6 application?

浪子不回头ぞ 提交于 2019-12-06 08:23:45
This Q&A refers to and can be used for foll. purposes: Send message from IE browser to vb6 app via ActiveX dll Send message from ActiveX dll to vb6 app Send message from C#.net (dll) to vb6 app I have read this article but doesn't seem to be very clear for my purpose... I have also referred to this article to create ActiveX object and have implemented an ActiveX dll that I am calling from browser to launch an application on client side.. The dll checks whether the VB6 exe (process) is running, else runs the exe. If the exe is already running then I want to pass a parameter/message to the exe