Article View: fr.comp.lang.c
Article #124Re: Récuperation d'1 PID en C and a question myself :)
From: nightstalker
Date: Tue, 11 Apr 2000 00:00
Date: Tue, 11 Apr 2000 00:00
53 lines
2685 bytes
2685 bytes
Julien Curto wrote: > Salut, > > 2 Questions : > > * Comment est-ce que peut-on r�cuperer un PID en C. > > * Comment peut-on savoir si un programme est d�j� activer en C. (ex. : > par recherche du PID) > > D'avance merci > > Merci de r�pondre � l'adresse indiqu�e. > > M�ll#99 i don't know french to well but i'll try to help you :) 1) getpid() gets the pid of your current running program. (type man getpid for more info) 2) some programs (like dhcpcd & gpm ) use a 'lock-file' in the /var/run dir they store their pid's there in a file named for example dhcpcd.pid when you try to start dhcpcd it checks if the file exists, if so : it gives you a warning and refuses to start unless you specify a parameter explicitly stating you want to run it. ofcourse these programs need to delete this file after they are done executing :) hope this helps ns. ps: consider writing your question in english next time :) lot's of ppl read newsgroups and don't know french ps2: to all of you out there : i noticed i could read /var/run/dhcpcd.pid as a normal user. i know that with a kernel patch you can disable certain programs from being listed by for example 'ps' .. couldn't this be a security hole ?? you can still know as a user that a certain program is running. (the /var/run dir is normally only used by programs started by root anyway, so why not make it readable/writable only by root ?) if this is a silly question, nevermind :) i'm running slackware btw
Technical Details
Message-ID:
<38F38C0A.5730A6AC@tvd.be>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<38F3C13C.1430B812@www.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: f5392,7807dc7f7063ea6b X-Google-Attributes: gidf5392,public X-Google-Thread: 10c696,7807dc7f7063ea6b X-Google-Attributes: gid10c696,public X-Google-Thread: 102e15,7807dc7f7063ea6b X-Google-Attributes: gid102e15,public X-Google-Thread: 114592,7807dc7f7063ea6b X-Google-Attributes: gid114592,public X-Google-Thread: f9822,7807dc7f7063ea6b X-Google-Attributes: gidf9822,public From: nightstalker <nstalkie@tvd.be> Subject: Re: Récuperation d'1 PID en C and a question myself :) Date: 2000/04/11 Message-ID: <38F38C0A.5730A6AC@tvd.be> X-Deja-AN: 609831504 Content-Transfer-Encoding: 8bit References: <38F3C13C.1430B812@www.com> X-Accept-Language: en Content-Type: text/plain; charset=iso-8859-1 X-Complaints-To: abuse@chello.be X-Trace: news.chello.be 955489530 195.162.214.221 (Tue, 11 Apr 2000 23:45:30 MET DST) Organization: Chello Usenet Service MIME-Version: 1.0 NNTP-Posting-Date: Tue, 11 Apr 2000 23:45:30 MET DST Newsgroups: fr.comp.lang.c,fr.comp.developpement,alt.comp.lang.learn.c-c++,comp.os.linux.development.apps,comp.os.linux.development.system