Run program with own pid

Discussion in 'Programming/Scripts' started by andipurwito, Sep 12, 2007.

  1. andipurwito

    andipurwito New Member

    Hi all..
    Can i run a program with my own pid from command prompt?
    Ex: # ./myprogram [pid]
     
  2. Ben

    Ben HowtoForge Supporter

    what do you mean with "your own pid"? Each process running gets a process id (PID) from the system. If the process ends, you won't see it anymore (e.g. in ps) and logically there is no PID anymore.

    Or what do you plan to do?
     
  3. andipurwito

    andipurwito New Member

    I mean: how to run program with my own PID?
    Example: ./myprogram 12345

    12345 is my own PID. Is there any option from Linux kernel to obtain like this?
     
  4. falko

    falko Super Moderator

    The PIDs are assigned automatically, you can't do that yourself.

    If you'd like to find out the PID of a certain process, take a look at
    Code:
    man pidof
     
  5. andipurwito

    andipurwito New Member

    Forgive me if this question seem stupid and wrong in how to explain.
    I just want to run the same program but with many of profile in the same time. And then i will take its pid later to identify each running profile.
    Example:
    # myprogram profile1 &
    # myprogram profile2 &
    # myprogram profile3 &
    How should i make this possible?
     
  6. Ben

    Ben HowtoForge Supporter

    then just do sth like
    And split the string (sry i am no bash expert for splitting strings ;) ) and grep the pid for that progammcall.
    Maybe you have to add an
    grep -v "grep \"yourpgroammcall\""
    so that the grep call does not exist in the output.
     

Share This Page