[opensuse-programming] Getting PID by process-name
Hi all. How do i get the PID of a process by the process-name? I'm looking for the same thing pgrep does, but as a C-function. Regards .....Volker -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-programming+help@opensuse.org
Hello, On Tue, 02 Dec 2008, Volker Poplawski wrote:
How do i get the PID of a process by the process-name?
Look at the sourcecode of pidof / pgrep. Basically both programms look through /proc/nnn/{cmdline,exe} and look for matching names. -dnh -- Better visibility is no good if the oncoming traffic crashes into you with its arm across its eyes from the sudden blindness. -- Graham Reed -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-programming+help@opensuse.org
On Tue, Jun 30, 2009 at 3:09 PM, David Haller<lists@dhaller.de> wrote:
Hello,
On Tue, 02 Dec 2008, Volker Poplawski wrote:
How do i get the PID of a process by the process-name?
Look at the sourcecode of pidof / pgrep. Basically both programms look through /proc/nnn/{cmdline,exe} and look for matching names.
Along those same lines, strace will get you to the answer even faster a lot of times. And you don't have to have the source handy either. Greg -- Greg Freemyer Head of EDD Tape Extraction and Processing team Litigation Triage Solutions Specialist http://www.linkedin.com/in/gregfreemyer Preservation and Forensic processing of Exchange Repositories White Paper - http://www.norcrossgroup.com/forms/whitepapers/Forensic%20Processing%20of%20... The Norcross Group The Intersection of Evidence & Technology http://www.norcrossgroup.com -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-programming+help@opensuse.org
Hello, On Tue, 30 Jun 2009, Greg Freemyer wrote:
On Tue, Jun 30, 2009 at 3:09 PM, David Haller<lists@dhaller.de> wrote:
On Tue, 02 Dec 2008, Volker Poplawski wrote:
How do i get the PID of a process by the process-name?
Look at the sourcecode of pidof / pgrep. Basically both programms look through /proc/nnn/{cmdline,exe} and look for matching names.
Along those same lines, strace will get you to the answer even faster a lot of times. And you don't have to have the source handy either.
I used 'strace pidof xemacs' for my answer, don't have the sources around ... ;) I use strace, ltrace, ltrace -S quite often. But to reimplement the functionality, it'd probably be better to have a look at the tried and tested implementations in the sources of pidof and/or pgrep and probably use copy and paste, eh? ;) On the other hand, I do quite often also look into sources. -dnh -- In the Beginning there was nothing, which exploded. -- Terry Pratchett, Lords and Ladies -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-programming+help@opensuse.org
On Tuesday 30 June 2009 21:09:02 David Haller wrote:
Hello,
On Tue, 02 Dec 2008, Volker Poplawski wrote:
How do i get the PID of a process by the process-name?
Look at the sourcecode of pidof / pgrep. Basically both programms look through /proc/nnn/{cmdline,exe} and look for matching names.
(got my clock set right now :) Well, i was hoping there was a better, more portable version than going through /proc. -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-programming+help@opensuse.org
participants (3)
-
David Haller
-
Greg Freemyer
-
Volker Poplawski