ipc

Linux进程间通信——匿名管道

自古美人都是妖i 提交于 2019-12-23 10:38:46
进程如果不是独立进程,那么它就需要和别的进程进行通信。在进程协作时可以采用共享一个缓冲区的方式来实现。当然,OS的IPC提供了一种机制,以允许不必通过共享地址空间来通信和同步其动作。这就不得不提Linux的的前身Unix。因为Linux一开始就是从这儿借鉴的。加上Linux从一开始就遵守POSIX标准。 Unix最早是由AT&T的贝尔实验室开发的,值得一提的是,在Unix操作系统发展的过程中,产生了许多副产物(POSIX标准也是副产物之一),其中最著名的应当是C语言。是的,它仅仅是个副产物。那个时候Ken Thompson 与Dennis Ritchie感到用汇编语言做移植太过于头痛,他们想用高级语言来完成第三版。后来他们改造了B语言,就形成了今天大名鼎鼎的C语言。这个自发明到现在这个物联网时代仍占据编程语言榜前10的稳固位置。不得不感叹其生命力的强大以及适应性的强大。当然,Ken Thompson 与Dennis Ritchie也是图灵奖得主。 到了1980年,有两个最主要的Unix的版本线,一个是UC Berkeley的BSD UNIX,另一个是AT&T的Unix。至今为止UC Berkeley仍在维护Unix(这学校真牛逼)。 最初的Unix的IPC包括,管道,FIFO,信号。贝尔实验室对Unix早期的进程通信进行了改进,形成了system V这个操作系统的IPC。它包括

Reading from FIFO after unlink()

十年热恋 提交于 2019-12-23 09:50:30
问题 I have created a FIFO, wrote to it and unlinked it. To my surprise I was able to read data from the fifo after unlinking, why is that? #include <fcntl.h> #include <sys/stat.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/wait.h> #define MAX_BUF 256 int main() { int fd; char * myfifo = "/tmp/myfifo"; /* create the FIFO (named pipe) */ mkfifo(myfifo, 0666); int pid = fork(); if (pid != 0) { /* write "Hi" to the FIFO */ fd = open(myfifo, O_WRONLY); write(fd, "Hi",

Stacking of Context Menus in Electron

风流意气都作罢 提交于 2019-12-23 07:27:38
问题 I am building an Electron based application that contains a grid containing unique rows. I would like a context-menu that is specific to each row. Here is an example: Although this screen shot is cropped, you can see there are multiple rows and each row contains separate data. Since I'd like to right-click on a row and get a unique context menu, I have implemented electron-context-menu, which does work on the first right click, but then subsequent right-clicks causes a stacking effect of

Daemon - Client IPC with Unix sockets

爱⌒轻易说出口 提交于 2019-12-23 04:49:17
问题 I have a launch daemon which I want to ask for status information from a user app. I implemented a client-server model (with the daemon as server) using unix sockets as described here: OS X - Communication between launch daemon and launch agent In fact it works well, when I run the daemon as a user process (for debugging), but it will fail when it is actually launched as root. I have read the TN on Daemons and Agents and the Daemon & Services Programming Guide. However, I could not find

libnl-3 includes broken?

岁酱吖の 提交于 2019-12-23 03:25:07
问题 I am trying to use libnl 3 (http://www.infradead.org/~tgr/libnl/) under Ubuntu to use netlink in order to get some information from the IPv6 Neighbour Cache. I am including a bunch of headers for this lib, but gcc already fails for the first one: #include <libnl3/netlink/netlink.h> There is no "main header", like libnl.h. >$ gcc netlink_test.c In file included from netlink_test.c:11:0: /usr/include/libnl3/netlink/netlink.h:24:36: fatal error: netlink/netlink-compat.h: No such file or

Android IPC介绍

ぃ、小莉子 提交于 2019-12-23 03:18:05
一. Android IPC 简介 IPC全称 Intent-Process Communication,含义为进程通信或跨进程通信,是指两个进程之间的通信。 二. Android中的几种IPC方法 1. 使用Bundle 当在一个进程中启动了另一个进程的Activity 、Service 和Receiver ,我们可以将需要传输的数据放入Bundle中并通过Intent传递出去 2. 使用文件共享 两个进程可以通过读写同一个文件来交换数据,也就是说A进程将数据写在共享文件,B进程通过读取共享文件获取A进程的数据 3. 使用ContentProvider 4. 使用Socket 5. 使用BroadCast 来源: https://www.cnblogs.com/Ayinger/p/11966595.html

Windows API: find process for a file mapping handle

隐身守侯 提交于 2019-12-23 03:09:18
问题 I created an SSH agent (similar to PuTTY's pageant.exe) which has a predefined protocol: Authentication requests are sent to the agent window via WM_COPYDATA containing the name of a file mapping: // mapname is supplied via WM_COPYDATA HANDLE filemap = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, mapname); Is it possible to find out which process (ultimatively, the process name) created a particular file mapping? I can use GetSecurityInfo on "filemap" to get the security attributes (SID, GID,

How can we share the data using shared memory segment with “Object” between two managed processes?

南笙酒味 提交于 2019-12-23 01:16:20
问题 How can I share the data between two managed processes using shared memory segments? I am using "object" inside C++/CLI code to share the data with some other part of memory in the other process. I am using following code segment. #define BUFFER_SIZE 32768 #pragma data_seg (".SHAREDMEMORY") bool _Locked = false; bool _Initialized = false; unsigned char[10000] data = NULL; #pragma data_seg() #pragma comment(linker,"/SECTION:.SHAREDMEMORY,RWS") but I need it to be: #pragma data_seg ("

进程间通信(IPC)

给你一囗甜甜゛ 提交于 2019-12-23 00:31:14
以下是阿鲤对Linux下进程间通信的总结,希望对大家有所帮助;若有误请慷慨指出。 因为每一个进程都要有一个独立的虚拟地址空间,在保证了进程的独立性同时,却使得进程间无法通信;所以必须要借助一定的方法进行进程间通信,阿鲤在这里主要介绍以下几种通信方式(以下均为SystemV标准) 1:管道 -- 用于进程间的数据传输 2:共享内存 -- 用于进程间的数据共享 3:消息队列 -- 用于进程间的数据传输 4:信号量 -- 用于时间进程间控制 注:以下的代码实现均为centos7环境; 一:管道 -- 用于进程间的数据传输 1:本质: 通过让多个进程都能访问到同一块内核中的缓冲区,通过半双工通信实现数据传输 (半双工通信:方向可选择的单项通信) 2:分类: 匿名管道 和 命名管道 3:匿名管道: 这块内核中的缓冲区没有标识符 3.1: 因为匿名管道没有标识符,故只能用于具有亲缘关系之间的进程通信; 3.2: 在创建管道时,操作系统会提供两个操作句炳(文件描述符),其中一个用于从管道读取数据,一个用于向管道写入数据;但是我们在使用时往往会关闭一个使用一个 3.3: 我们都知道子进程是通过复制父进程进行创建的所以,子进程也会复制到父进程所创建管道的操作句柄,故父子进程便可以通过父进程所创建的匿名管道进行进程间通信。 3.4: int pipe(int pipefd[2]): 创建一个匿名管道

Communicate with a WallpaperService

╄→尐↘猪︶ㄣ 提交于 2019-12-22 19:15:39
问题 Is there any way to directly communicate with a WallpaperService from an Activity ? It doesn't look like I can use the normal service communication classes because the onBind method is declared final in the WallpaperService class I'm extending. Worth noting that I'm referring to my WallpaperService not any . Any workarounds if this isn't possible? 回答1: My solution was to use local sockets. I created an instance of a LocalServerSocket in the constructor of my wallpaper's Engine . Here's a