LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Need a challange?!? Try to solve this one: INTER PROCES COMMUNICATION (https://www.linuxquestions.org/questions/linux-software-2/need-a-challange-try-to-solve-this-one-inter-proces-communication-109878/)

rkrijger 10-29-2003 08:12 AM

Need a challange?!? Try to solve this one: INTER PROCES COMMUNICATION
 
This is a nice problem:

- i want to have a program with UI-buttons that performs the following:
(1) if i press a button to "ON" it activates a shell script
(2) if i press a button to "OFF" it kills this shell script
(3) if the shell script terminates (OR gets killed by anyone else),
the corresponding button in the program should go to "OFF"
and (last but not least)
(4) it should be possible to have multiple instances of this program that all have valid indicators for the corresponding scripts that run (or not)

Example:
=======

The program CONTROL that has a button "Start Production"
I invoke this program CONTROL several times.
Selecting the button in one of the CONTROL apps, invokes the shell script "startprod" AND (!!!) it should lit all corresponding buttons "Start Production" in the other instances of CONTROL.

Then I manually kill this script.

Now all buttons should go to "OFF"...

Well, taking care of (1) and (2) is not so difficult: I have created an "in between script" that is called with 1 (button was pressed) or 0 (button was released) by the program CONTROL. The "inbetween script" kills or calls "startprod" (i store pid's in files).

But taking care of (3) and (4) is a bit more difficult... Any ideas?!?

Let's find out who the clever guys are here!!! :)

tefal 10-29-2003 09:43 AM

How about when the process 'startprod' is created, store the PID of the process in a file somewhere and have all instances looking for this file at regular intervals.

If the file exists, read in the process ID and monitor it to see if it is still running. If it dies, then it no longer exists and each Control process reacts similarly.

Just make sure that if the process is killed, then either remove the file containing the PID or empty it.

-Tefal


All times are GMT -5. The time now is 12:02 PM.