IPC passing for Linux User space exe
We have a programme, lets call it Y.exe. It runs on an embedded system and it runs without exiting (i.e. the syste开发者_运维百科m starts, loads the Linux kernel, all the kernel modules, then Y.exe, and Y never returns (user space)).
Now there comes a time when we are required to change how Y.exe is running i.e. turn on some debug, make it take certain other code routes for tests, etc.
The current way of doing this is to compile, and recompile Y to handle each test. This seems like a waist of time and we should be able to dynamically set the conditions.
I would love to use something like the proc/debug system from the kernel where you can simply do something like:
echo 1 > /proc/test_y
to enable tests, etc.
Seeing that the proc/debug are kernel level items, they cannot be used for user space executables(?).
Apart from implementing a full on IPC through message Q's or TCP, are there any other ways to implement similar functionality?
Thanks.
Have it check for the existence of a flag file somewhere through each event loop iteration?
Set a signal handler for SIGUSR1
? SIGUSR2
?
Upon any of these occurring, set a flag value in the program that will perform the tests or output the debugging information, and then is toggled after receiving another, or the flag file disappearing, etc.
Something like the above should achieve similar functionality to what you're talking about. The signals would be more immediate (and probably more straightforward), but either mechanism should be sufficient.
精彩评论