how to obtain pid

This is a discussion on how to obtain pid within the C Programming forums, part of the General Programming Boards category; hi there, how can i get the pid of a different process using its name? are there any functions that ...

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    351

    how to obtain pid

    hi there,

    how can i get the pid of a different process using its name?

    are there any functions that do this?

    TIA,

    rotis23

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    In unix you might try getpid().

    www.rt.com/man
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    And for windows

    GetWindowThreadProcessId()

  4. #4
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Location
    Bangalore, India
    Posts
    345
    Originally posted by Hammer
    In unix you might try getpid().

    www.rt.com/man
    getpid() gives you the PID of the current process and not of any other process.

    >how can i get the pid of a different process using its name?
    It depends on what flavor of UNIX you are using. In Digital, you have a pseudo mount point called /proc/, in which each file is named after a process' PID. You can read a lot of information of a process just using read() on each of these files in here. But again, reading these files depends upon who the user is [permissions]. The best bet for you would be using the command 'ps'.

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    oops! Should have read the question properly!
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. crazy pipe/fork
    By fortune2k in forum C Programming
    Replies: 8
    Last Post: 03-13-2009, 11:28 AM
  2. wrong pid with GetWindowThreadProcessId?
    By electrohippi in forum Windows Programming
    Replies: 2
    Last Post: 11-11-2008, 07:54 PM
  3. A small question about fork( )
    By mlhazan in forum C Programming
    Replies: 4
    Last Post: 08-13-2008, 08:18 PM
  4. Getting other processes class names
    By Hawkin in forum Windows Programming
    Replies: 3
    Last Post: 03-20-2008, 04:02 PM
  5. process info from PID
    By mihaa in forum Linux Programming
    Replies: 3
    Last Post: 12-12-2007, 08:31 AM

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