M
Muffinman
Hello all,
I have two C programs which need each other. They both do some realtime
tasks (listening to message queue and Alsa mixer events) and to keep
that realtime I've got them in two separate applications. Now I could
create some bash script to execute both in the proper order, but I would
rather do that in C, to keep it a bit more user friendly. The order of
tasks is as follows:
App1: Read configuration file -> open serial port -> open message queue
(creates queue) -> listen to message queue (receives messages from both
C and PHP scripts). -> if message received translate and send to serial
port -> listen to message queue, etc.
After the message queue is opened above I would like to open a second
application which does the following:
App2: Open message queue (may not create queue) -> listen for Alsa mixer
events -> event is formatted properly and send to message queue ->
listen for Alsa mixer events, etc.
How do I execute this App2 at the proper moment? When searching online I
only get to forking the process. However, the applications don't share
any code, so that would be combining two different apps in one for the
sake of having just one file (is that what forking is about?). In
addition I would have to split the parent and child at the beginning of
main() and send e.g. a SIGUSR1 from App1 to App2 when it has opened its
message queue to tell App2 it may continue to execute its code (and
prevent it from opening the queue while it does not yet exist).
All I need is App2 to open at the proper moment and for App1 to have the
pid of App2 so it can send a SIGTERM and have a proper shutdown when needed.
I hope I've made my point clear. Can someone tell me how I can approach
this task?
Thanks in advance, Maarten
I have two C programs which need each other. They both do some realtime
tasks (listening to message queue and Alsa mixer events) and to keep
that realtime I've got them in two separate applications. Now I could
create some bash script to execute both in the proper order, but I would
rather do that in C, to keep it a bit more user friendly. The order of
tasks is as follows:
App1: Read configuration file -> open serial port -> open message queue
(creates queue) -> listen to message queue (receives messages from both
C and PHP scripts). -> if message received translate and send to serial
port -> listen to message queue, etc.
After the message queue is opened above I would like to open a second
application which does the following:
App2: Open message queue (may not create queue) -> listen for Alsa mixer
events -> event is formatted properly and send to message queue ->
listen for Alsa mixer events, etc.
How do I execute this App2 at the proper moment? When searching online I
only get to forking the process. However, the applications don't share
any code, so that would be combining two different apps in one for the
sake of having just one file (is that what forking is about?). In
addition I would have to split the parent and child at the beginning of
main() and send e.g. a SIGUSR1 from App1 to App2 when it has opened its
message queue to tell App2 it may continue to execute its code (and
prevent it from opening the queue while it does not yet exist).
All I need is App2 to open at the proper moment and for App1 to have the
pid of App2 so it can send a SIGTERM and have a proper shutdown when needed.
I hope I've made my point clear. Can someone tell me how I can approach
this task?
Thanks in advance, Maarten