ipc

message queue in C: implementing 2 way comm

浪子不回头ぞ 提交于 2020-01-13 14:55:48
问题 I am a student and a begineer in C. I want to implement 2 way communication using message queue in C linux. Do I need two queues or only one to get this done? Also I would like to know can I send data(shown in code) to another process or i need to declare it as a character array. typedef struct msg1 { int mlen; char *data; }M1; typedef struct msgbuf { long mtype; M1 *m; } message_buf; Thanks in advance :) 回答1: Also I would like to know can I send data(shown in code) to another process or i

Processes hang on read

拈花ヽ惹草 提交于 2020-01-13 13:10:21
问题 The following code reads messages from other processes through a pipe. All processes correctly print out all the messages, but then they will never proceed past the while loop. Tried debugging in Eclipse, after reading reading all the messages, it will just stop at that while loop. The index is a number assigned to each process. The first process would have index == 0. The message itself is simply the index of the process sending the message. while((n = read(fd[index][0], &mymsg, sizeof(int))

Linux基础入门--进程间通信--消息队列

扶醉桌前 提交于 2020-01-13 00:18:39
Linux基础入门--进程间通信--消息队列 1.概述 2.key值和ID值 3.消息队列IPC原理 1.概述 System V提供的IPC机制主要有消息队列,信号量和共享内存3种机制。和文件一样,IPC在使用前必须先创建,每种IPC都有特定的生产者,所有者和访问权限。使用ipcs命令可以查看当前系统正在使用的IPC工具: [root@localhost swz] # ipcs ------- Shared MemorY Segments --------- //共享内存 key shmid ower perms bytes nattch status ------- Semaphore Arrays --------- //信号量 key shmid ower perms nsems ------- Message Queues ----------- //消息队列 key shmid ower perms used-bytes messages 由以上可以看出,一个IPC工具至少包含key值,ID值,拥有者,权限和使用的大小等关键信息。如果需要手动删除某个IPC机制,可以使用ipcrm命令。 2.key值和ID值 Linux系统为每个IPC机制都分配了唯一的ID,所有针对该IPC机制的操作都使用该ID值。因此,通信的双方都需要通过某个方法来获取ID值

Isolating and multiply instantiating a C library in-process

♀尐吖头ヾ 提交于 2020-01-12 14:57:19
问题 We have a C library (.lib windows & .a linux) that only allows creation of a singleton and that also doesn't shut down properly (memory leaked and threads left alive) having been once instantiated. Rewriting it and hunting down the bugs aside, is there a simple way to isolate this kind of misbehaving code in-process such that the singleton restriction can be removed, and the unclean tidyup can be sandboxed? I am mainly interested in any in-process options, if indeed there are any. A seperate

C - fork() and sharing memory

微笑、不失礼 提交于 2020-01-12 13:47:14
问题 I need my parent and child process to both be able to read and write the same variable (of type int) so it is "global" between the two processes. I'm assuming this would use some sort of cross-process communication and have one variable on one process being updated. I did a quick google and IPC and various techniques come up but I don't know which is the most suitable for my situation. So what technique is best and could you provide a link to a noobs tutorial for it. Thanks. 回答1: Since you

How to use the existing services in DBus?

青春壹個敷衍的年華 提交于 2020-01-11 13:29:27
问题 I am able to use the dbus commands like dbus-send and etc. But i am not getting how to use the api's of dbus efficiently to write sample applications. Can any one please tell me how to receive the data from the dbus. I am not getting how to use the existing services in dbus like org.freedesktop.NetworkManager Please tell me the proper way to access and use the services of dbus. Please post some sample examples and also suggest me what are the rules we have to follow while using a service. i

Android IPC Remote service call display Error

一个人想着一个人 提交于 2020-01-11 12:15:00
问题 I want to make one demo application regarding the IPC communication .(Communication between Service). I am using AIDL for that . I found most of tutorial the RemoteService and Client are in same package . I actually do it separately ,While passing the object I am using Parcelable Method and facing Error ... It said like The RemoteService Signature unable to find your class.. I displayed my Logcat Below also : If you have any solution please guide me ...or any interdependent server client

Redirecting stdin and stdout where stdin closes first

假装没事ソ 提交于 2020-01-11 09:21:08
问题 This is actually related to another question I had that was already answered. That question is here: Redirecting stdout of one process object to stdin of another My issue is (I think) that the program who is getting the input should exit before the program outputting. Here is the bash equivalent of what I'm doing: tccat -i /dev/sr0 -T 1 | ffmpeg -i - -r 1 -t 1 -s 96x72 -ss 5 /tmp/wsmanage/preview_tmp/test\%03d.jpg This just uses a program called tccat to read the first title of a dvd. That

Best IPC for VB6 and .net application

天涯浪子 提交于 2020-01-11 07:12:18
问题 In our application (a document management system) we are supposed to be notified of screen changes (or notify the other program of screen changes) in order to keep the two applications looking at the same data, one being the order fulfillment app, the other the document viewer of the original fax. The fulfillment app is written in vb6 and the document manager is in .net 3.5 (c#). It runs on a terminal server so it also has to be session aware. The document viewer or the fulfillment app may be

Docker 容器资源隔离 namespace(十)

纵饮孤独 提交于 2020-01-11 00:39:45
一、简介 Linux Namespace 是 Linux 提供的一种内核级别环境隔离的方法。不知道你是否还记得很早以前的 Unix 有一个叫 chroot 的系统调用(通过修改根目录把用户 jail 到一个特定目录下),chroot 提供了一种简单的隔离模式:chroot 内部的文件系统无法访问外部的内容。Linux Namespace 在此基础上,提供了对 UTS、IPC、mount、PID、network、User 等的隔离机制。 举个例子,我们都知道,Linux 下的超级父亲进程的PID是1,所以,同 chroot 一样,如果我们可以把用户的进程空间 jail 到某个进程分支下,并像 chroot 那样让其下面的进程 看到的那个超级父进程的 PID 为1,于是就可以达到资源隔离的效果了(不同的 PID namespace 中的进程无法看到彼此) Linux Namespace的6大类型 类型 功能说明 Mount Namespace 提供磁盘挂载点和文件系统的隔离能力 IPC Namespace 提供进程间通信的隔离能力 Network Namespace 提供网络隔离能力 UTS Namespace 提供主机名隔离能力 PID Namespace 提供进程隔离能力 User Namespace 提供用户隔离能力 二、Mount Namespace Mount