Thread: Get pid based on command

  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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    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.

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, 03:12 PM
  5. Command Interface : Black Box testing
    By GlowinCelica in forum C Programming
    Replies: 1
    Last Post: 03-10-2003, 10:21 PM