Re: Question on SSH hang on exit when running Java background process

Try using screen to launch the program in another session. Screen will then let you disconnect cleanly while letting the program continue to run.


Sent from my BlackBerry wireless handheld.

-----Original Message-----
From: YU Jiazi <yujiazi@xxxxxxxxx>
Date: Fri, 27 Apr 2007 22:25:44
Subject: Question on SSH hang on exit when running Java background process

hi, all

I'm not sure if i should ask this question in this maillist, i am sorry
if this mail bothered you. :)

My problem is that my SSH client hang on "exit" if I run a java program
as a background process.
Here is the sample java program:

public class Test
public static void main(String argv[])
while(true) {
System.out.println("Hello world");
} catch(Exception ex) {

then I save it as, and compile, run it as follow in a
terminal connected by ssh(my ssh client is putty 0.58):

java -cp . Test &

then putty hang, it seems that the SSH connection is still alive and
waiting for the java program to exit.
If a close the putty and login the server again, i can see the program
is still running.

This problem puzzled me a long time, since i have to run a server
program written by java and I can't
exit ssh client normally. At first i guess it was caused by signals, by
it seems that when i type "exit" even
i close the ssh client, the program didn't get a SIGHUP signal, or it
would exit by receiving a SIGHUP.

Anyway, could anyone help me on this problem?

Relevant Pages