Hello Everyone
I have an embedded system running monta vista linux that on bootup may or may not run a process called X. The name of this process is always the same but the process ID might vary/change.
If its not running it can be created anytime by the user through a webbased GUI from a PC running Windows. In addition the user may have a control application running on the PC and he/she can start process X from the control application as well. There MUST only be one instance of process X running at anytime on this system.
So now for my question: How do I in an easy way check if process X is running or not when for example trying to start it using the control application? It might already have been started using the Web GUI or even at bootup?
I have though I could use the 'ps' command and try to capture the output and then parse it for the process name X but I feel that there must be some better way of doing it. Parsing can take time and I also need to alocate a buffer for storing the data before parsing. The size of this buffer has to be big enough to handle the worst case number of processes and that will wast my precious memory(embedded 4MB).
Any input would be great.
Regards Andreas