Ethical Hacking

Learn to find vulnerabilities before the bad guys do! Gain real world hands on hacking experience in our state of the art hacking lab. Course designed and taught by expert instructors with years of penetration testing experience. 12 student maximum in every class. Certification attempt included in every package.
Computer Forensics Training at InfoSec Institute

Gain the in-demand skills of a certified computer examiner, learn to recover trace data left behind by fraud, theft, and cybercrime perpetrators. Discover the source of computer crime and abuse at your organization so that it never happens again. All of our class sizes are guaranteed to be 12 students or less to facilitate one-on-one interaction with one of our expert instructors.




Network Security Secure-Shell
[Top] [All Lists]

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

Subject: Re: Question on SSH hang on exit when running Java background process
Date: Sat, 28 Apr 2007 11:17:06 +0800
thank you for your help.
Since i have to send signals to the process, eg, Send SIGINT to tell the process to shutdown,
send SIGHUP to tell the process to reload configuration. But if i use "nohup", it seems that the
process can not receive any signal which is unexpected.

YU Jiazi

Francois Bolduc wrote:
Question on SSH hang on exit when running Java background process
Just call your program with nohup like this:
$ nohup java -cp . Test &
 
That will tie the background process to PID 1, freeing up the current shell to exit whenever you want, whether the java program is done or not. Output goes to nohup.out by default in the current folder.
 
François Bolduc
Consultant
FUJITSU CONSEIL (Canada) inc. 
Bureau : 613.238.2697
francois.bolduc@ca.fujitsu.com

From: listbounce@securityfocus.com on behalf of YU Jiazi
Sent: Fri 4/27/2007 10:25 AM
To: secureshell@securityfocus.com
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[])
    {
          try{
                while(true) {
                    System.out.println("Hello world");
                    Thread.sleep(1000);
                }
          } catch(Exception ex) {
                ex.printStackTrace();
          }
    }
}

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

javac Test.java
java -cp . Test &
exit

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?



<Prev in Thread] Current Thread [Next in Thread>