ipc

Interprocess communication in Lua with Example?

霸气de小男生 提交于 2021-01-21 10:26:32
问题 I have been struggling a lot to get this to work. Can someone provide an example with any LUA api of 2 scripts that pass a message back and forth. I have tried Oil, lua-ipc and zeromq. But I face several missing libraries issues. The ultimate goal is to pass a vector of numbers from one Lua process to another Lua process (with a different version of Lua) without going through disk. Here is a similar example in python of IPC in a single file. Something similar in lua would be extremely helpful

Android ipc LocalSocket vs Binder (AIDL)

谁都会走 提交于 2021-01-21 08:20:11
问题 I want every app to be able to send data to my service. Therefore I need inter process communication. Every page I can find proposes to use Messenger, AIDL or Intents (BroadcastReceiver). So far what I could figure out by building some test apps is that BroadcastReceiver is extremely slow and messages can get lost without notification if sending with multiple threads inside while(true) loop. AIDL and Messenger are not only complicated to implement (service is needed, binder,...) but can

linux共享内存

余生颓废 提交于 2021-01-05 10:03:46
本文使用system v api,利用共享内存实现了简单的IPC通信。 头文件svshm_xfr.h #include <stdio.h> #include <sys/shm.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #define SHM_KEY 0x1234 #define OBJ_PERMS (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) #define WRITE_SEM 0 #define READ_SEM 1 #ifndef BUF_SIZE #define BUF_SIZE 1024 #endif struct shmseg { int cnt; char buf[BUF_SIZE]; }; 写程序svshm_xfr_writer.c,从标准输入写入共享内存。 #include "svshm_xfr.h" int main(int argc, char **argv) { int shmid, bytes, xfrs; struct shmseg *shmp; shmid = shmget(SHM_KEY, sizeof(struct shmseg), IPC_CREAT | OBJ_PERMS); if (shmid == -1)

Saving the output of a child process in a variable in the parent in NodeJS

血红的双手。 提交于 2020-12-29 13:15:20
问题 I would like to start a child process in NodeJS and save it's output into a variable. The following code gives it to stdout: require("child_process").execSync("echo Hello World", {"stdio": "inherit"}); I have something in mind that is similar to this code: var test; require("child_process").execSync("echo Hello World", {"stdio": "test"}); console.log(test); The value of test was supposed to be Hello World . Which does not work, since "test" is not a valid stdio value. Perhaps this is possible

Saving the output of a child process in a variable in the parent in NodeJS

那年仲夏 提交于 2020-12-29 13:12:25
问题 I would like to start a child process in NodeJS and save it's output into a variable. The following code gives it to stdout: require("child_process").execSync("echo Hello World", {"stdio": "inherit"}); I have something in mind that is similar to this code: var test; require("child_process").execSync("echo Hello World", {"stdio": "test"}); console.log(test); The value of test was supposed to be Hello World . Which does not work, since "test" is not a valid stdio value. Perhaps this is possible

Saving the output of a child process in a variable in the parent in NodeJS

纵饮孤独 提交于 2020-12-29 13:08:27
问题 I would like to start a child process in NodeJS and save it's output into a variable. The following code gives it to stdout: require("child_process").execSync("echo Hello World", {"stdio": "inherit"}); I have something in mind that is similar to this code: var test; require("child_process").execSync("echo Hello World", {"stdio": "test"}); console.log(test); The value of test was supposed to be Hello World . Which does not work, since "test" is not a valid stdio value. Perhaps this is possible

sending signal from parent to child

限于喜欢 提交于 2020-12-01 07:15:08
问题 I am using this tutorial from website http://www.code2learn.com/2011/01/signal-program-using-parent-child.html and trying to understand why signal is not recieved by child? here is the code: #include <stdio.h> #include <signal.h> #include <stdlib.h> void sighup(); /* routines child will call upon sigtrap */ void sigint(); void sigquit(); void main() { int pid; /* get child process */ if ((pid = fork()) < 0) { perror("fork"); exit(1); } if (pid == 0) { /* child */ signal(SIGHUP,sighup); /* set

Android AIDL 原理解析

隐身守侯 提交于 2020-11-03 03:29:01
Android AIDL 原理解析 如果去阅读Android的源代码,就会发现里面大量用到了Binder、AIDL相关知识,比如当我们去使用 AMS 、 PMS 、 WMS 这些核心服务,因为他们都运行在 system_server 进程,普通应用想调用他们提供的服务(例如: startActivity() ,就需要 AMS 来实现),就必须要跨进程调用,因此,我们在阅读代码之前,必须先去尝试理解Binder、AIDL相关知识。 为什么要使用AIDL呢? 通过AIDL,可以让本地调用远程服务器的接口就像调用本地接口那么简单,让用户无需关注内部细节,只需要实现自己的业务逻辑接口,内部复杂的参数序列化发送、接收、客户端调用服务端的逻辑,你都不需要去关心了。 一 从一个例子开始 我们通过一个简单的跨进程调用的例子来理解AIDL。 设计一个简单的场景: 我们有一个 CoreService 运行在 ":core" 进程中,提供文件下载服务,我们会在Activity中去bind这个Service,并且调用它为我们提供的服务。 实现起来很简单,只需要以下几个步骤: 定义一个AIDL文件 interface IDownloadService { /** * 下载 * @param url */ void download(String url); /** * 删除下载任务 * @param url