commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mladen Turk (JIRA)" <j...@apache.org>
Subject [jira] Closed: (DAEMON-103) [procrun] net stop command fails, when the Java application exits by using System#exit().
Date Thu, 11 Feb 2010 19:10:27 GMT

     [ https://issues.apache.org/jira/browse/DAEMON-103?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Mladen Turk closed DAEMON-103.
------------------------------

    Resolution: Won't Fix

If using jvm.dll the main() method becomes the part of the service process.
Actually it is called from a separate thread and procrun waits until it terminates
(main() method returns)
If you call the System.exit it will cause service exit without a chance to
report to the service manager that the application exited cleanly.

Solution is to use the exit hook inside the main method, and
that is what daemon java code does.

> [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