Re: [LIP] check instance of a running application

Raj Mathur <[email protected]>
Newsgroups gmane.user-groups.linux.india.programmers
Message-ID <[email protected]>
>>>>> "Ram" == rammohhan2000  <Ram> writes:

    Ram> Hi all, In Linux , Thr Coding in c how can i check whether my
    Ram> application is running or not . i.e i have written a small c
    Ram> program which will run as a daemon.When i run the same
    Ram> program again it should check whether previous instance is
    Ram> running or not(preferbly with the application name) , if
    Ram> running then i have to pass a value to the running
    Ram> application .

    Ram> For checking whether app is still running , I tried by
    Ram> writing the PID value to a file and later checked whether it
    Ram> exists or not. is there any other way to do this....

Create a 1-byte file in /tmp and put a lock on it.  If the lock fails
then the application is already running.  If it succeeds, this is the
first instance.

Oh, and, please spell.

Regards,

-- Raju
-- 
Raj Mathur                [email protected]      http://kandalaya.org/
       GPG: 78D4 FC67 367F 40E2 0DD5  0FEF C968 D0EF CC68 D17F
                      It is the mind that moves


-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.