Returning PID from execve family of functions?

This is a discussion on Returning PID from execve family of functions? within the Linux Programming forums, part of the Platform Specific Boards category; Hi all, Just wondering if it's possible to programatically get the PID of an app that has just been executed ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    4

    Returning PID from execve family of functions?

    Hi all,

    Just wondering if it's possible to programatically get the PID of an app that has just been executed
    using one of the execve(2) family of functions?

    For context, I'm writing an app that will execute an application specified on the command line,
    retrieve it's process id, and monitor various parameters over time, producing a graph.

    While I am writing this on Linux, it has to be portable so GNU/BSD extensions to ANSI C aren't
    any use to me unfortunately.

    Any ideas at all would be appreciated, I have the feeling I'm missing something simple :-/

    TIA,

    Ruairi

  2. #2
    Stewdent
    Guest
    are you using fork to spawn a child process which then uses one of the execve(2) family of functions?

    If so upon successful completion, fork() and fork1() return 0 to
    the child process and return the process ID of the child
    process to the parent process.

    Hope that helps

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    4
    Thanks for the reply 'Twas just what I needed.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. returning arrays from functions
    By Leeman_s in forum C++ Programming
    Replies: 11
    Last Post: 06-05-2002, 10:00 PM
  2. API "Clean Up" Functions & delete Pointers :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 05-10-2002, 06:53 PM
  3. returning functions w/ sockets
    By JagWire in forum Windows Programming
    Replies: 4
    Last Post: 03-11-2002, 04:00 PM
  4. Passing & Returning Strings from Functions
    By nisaacs in forum C Programming
    Replies: 1
    Last Post: 01-30-2002, 04:34 AM
  5. Class accessor functions returning strings?
    By Shadow12345 in forum C++ Programming
    Replies: 6
    Last Post: 12-31-2001, 11:48 AM

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