Get pid based on command

This is a discussion on Get pid based on command within the Linux Programming forums, part of the Platform Specific Boards category; Is there a function somewhere that will let me pass it the executable file name and it will return the ...

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    62

    Get pid based on command

    Is there a function somewhere that will let me pass it the executable file name and it will return the pid (if its running)?

    I thought I'd ask before writing a function to trawl through /proc/xxxx/cmdline for all processes.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,671
    What if the same executable is running several times?

    Nothing springs to mind for what you want.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem with "touch" command in c program
    By Moony in forum C Programming
    Replies: 10
    Last Post: 08-01-2006, 09:56 AM
  2. why page based I/O can improve performance?
    By George2 in forum C Programming
    Replies: 1
    Last Post: 06-12-2006, 07:42 AM
  3. using an operating system command in c
    By clearrtc in forum C Programming
    Replies: 2
    Last Post: 05-21-2006, 04:26 PM
  4. in program command console
    By howzer in forum C++ Programming
    Replies: 11
    Last Post: 03-19-2006, 02:12 PM
  5. Command Interface : Black Box testing
    By GlowinCelica in forum C Programming
    Replies: 1
    Last Post: 03-10-2003, 09:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21