Process handling with Runtime.exec()

Discussion in 'Java' started by Natanael Mignon, May 23, 2004.

  1. Good evening to you,

    what I am trying to do is start an external process, let it live and
    destroy it later on (by call of a method, i.e. when it is not needed
    anymore). Now this process is a ssh commandline opening a ssh-tunnel
    over which I want to communicate. After this communication is done, I'd
    like to end the ssh-process.

    At the moment I try it this way:

    Process proc = null;
    ....
    proc = Runtime.getRuntime().exec(sshCommandLine);
    ....
    (method invoked for closing)
    proc.destroy();

    Unfortunately, I keep getting a NullPointerException from proc.destroy()
    - the process seems to have disappeared (but in fact it is still there).

    I need to keep track of the process - but I cannot get a pid or
    something like that back from Runtime.exec() nor could I find any other
    useful Classes or Methods helping me there.
    Furthermore there is no way telling, whether the exec() has been
    successful at all, I think. Asking for the returnValue tells me the
    process has not yet exited. Humm.

    Any ideas and help is highly appreciated. :)

    Kind regards
    --
    - Nat

    www.bleeding.de | www.metal-germany.de

    -= Bleeding for Metal | c/o Madhouse Of Cain =-
    -= P.O. Box 39 23 | 30039 Hannover | Germany =-
     
    Natanael Mignon, May 23, 2004
    #1
    1. Advertising

  2. Andrew Thompson, May 23, 2004
    #2
    1. Advertising

  3. Andrew Thompson wrote:
    > Please do not multi-post Natanael..

    Sorry, my fault. My mind was a little numb after about 10 hours of
    martyring it, I guess.

    To those interested: There is an answer with very good hints and ideas
    in <40b19afe$>.

    Regards
    --
    - Nat

    www.bleeding.de | www.metal-germany.de

    -= Bleeding for Metal | c/o Madhouse Of Cain =-
    -= P.O. Box 39 23 | 30039 Hannover | Germany =-
     
    Natanael Mignon, May 24, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Zsolt Koppany
    Replies:
    2
    Views:
    7,136
    SaintMagoo
    Mar 5, 2011
  2. MARTIN Herve \(EXT\)
    Replies:
    1
    Views:
    1,462
    Anthony Borla
    Nov 27, 2003
  3. Nishi Bhonsle
    Replies:
    2
    Views:
    23,601
    pahujadeepanshu
    Nov 30, 2009
  4. rabbits77
    Replies:
    1
    Views:
    509
    John C. Bollinger
    Feb 25, 2004
  5. Hal Vaughan
    Replies:
    11
    Views:
    1,124
    Gordon Beaton
    May 22, 2006
Loading...

Share This Page