0

So my task is to communicate between 3 processes using signals and named pipes. It has to work like that for example : I want to close all programs and free resources of all processes, to do that I send SIGUSR1 to process B(for example), that process saves data in pipe about what I want to do, sends signal to other 2 processes, they read pipe and depending of what was written in pipe they either close, stop communication between each other or continue communication (using msg queues).

My issue is that I could just make 6 pipes between them so each pipe has one reader and one writer like 1-2 2-1,1-3,3-1 etc. but that would require a lot of work so I was wondering if there would be any simpler solution to that problem.

I wanted to use one pipe and open it as read write in all processes although I realised that one pipe can have one writer and reader.

Does anyone have any simplier solution to that problem?

Michal
  • 23
  • 3
  • 1
    Can you use Unix domain sockets (or socket pairs) instead of pipes? Then you'd only need three (pairs), because they are bidirectional. You could use an Unix domain datagram socket instead of message queues too; so just two per process, handling all interprocess communications. If you must use named pipes / FIFOs, then note that each process has only four ends (two read ends, and two write ends); it's not that much work at all. Do the three processes have a common parent (that forks them), or are they run separately by a human user? – Nominal Animal Jan 04 '19 at 17:16
  • Yeah, they all have one common parent where i exec /fork them into 3 processes. This is project for class so I have to do that using named pipes. – Michal Jan 05 '19 at 19:21

0 Answers0