commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hikaru Sato (JIRA)" <j...@apache.org>
Subject [jira] Created: (DAEMON-103) [procrun] net stop command fails, when the Java application exits by using System#exit().
Date Wed, 26 Sep 2007 04:21:50 GMT
[procrun] net stop command fails, when the Java application exits by using System#exit().
-----------------------------------------------------------------------------------------

                 Key: DAEMON-103
                 URL: https://issues.apache.org/jira/browse/DAEMON-103
             Project: Commons Daemon
          Issue Type: Bug
    Affects Versions: Nightly Builds
         Environment: Windows XP (32bit)
            Reporter: Hikaru Sato


net stop command output a following message and failed.

C:\temp>net stop servicename
System error 109 has occurred.

The pipe has been ended.

I made a following test case. when the test case exited by using return, net stop command
worked. But when it exited by using  System#exit(), it failed.

=== FROM HERE TEST CASE.

import java.net.ServerSocket;
import java.net.Socket;

public class TestService extends Thread {
    private static final int PORT = 8980;
    private static ServerSocket socket;

    public static void main(String[] args) throws Exception {
        if (args[0].equals("start")) {
            startService();
        } else if (args[0].equals("stop")) {
            stopService();
        } else {
            ;
        }
    }

    private static void startService() throws Exception {
        socket = new ServerSocket(PORT);
        TestService thread = new TestService();
        thread.start();
        thread.join();
    }

    private static void stopService() {
        try {
            Socket sock = new Socket("127.0.0.1", PORT);
        } catch (Exception e) {
        }

    }

    public void run() {
        try {
            while (true) {
                Socket cli = socket.accept();
                cli.close();
                System.exit(0); // net stop command fails.
//                return;// net stop command works well.
            }

        } catch (Throwable e) {
            ;
        }

    }

}
 


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message