JDK-4639189 : Back-ground process as service of winNT stops with log off operation
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 1.3.1_02,1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2002-02-18
  • Updated: 2003-04-22
  • Resolved: 2003-04-22
Related Reports
Relates :  
Description
The Java application as "Service" of Windows NT feature stops with log-off
operation.

This might be well-known issue, but some reason makes me update this issue again.(details, please see the comment.)


1. Reproduce

 1) Compile the attached sample code
     This program will output the date once 10 seconds to "SigTest.out" file.

 2) Install the "Service Installer" 

    As to the "Service Installer", please see the URL,
      http://www.kcmultimedia.com/javaserv

 3) Install the above Java application of 1) with "Service Installer"

 4) Set the "service" property
    - Open the [Control Panel]-[service]
    - Select the installed java application("sigtest")
    - Click the "Startup Button", set the "StartUp Type" to "Manual"
      and set the checkbox to "Allow Service to Interact with Desktop"

 5) Click the "Start Button"

    -> You can see the MS-DOS window show up.

 6) Please see the contents of "SigTest.out" file.

 7) Log off  from the NT system

 8) Log in again
    -> Please check whether the date information output to "SigTest.out"
       or not.
       You will not see the date information updated.

2. Configration

   - MPU    : Pentium IV 1.4[GHz]
   - Memory : 384 [MHz]
   - OS     : Windows NT (SP5, Japanese)
   - JDK    : Merlin and JDk1.3.1_02
        H:\>java -version
        java version "1.4.0"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
        Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

        H:\sigtest>java -version
        java version "1.3.1_02"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_02-b02)
        Java HotSpot(TM) Client VM (build 1.3.1_02-b02, mixed mode)

3. Sample Code

import java.io.* ;
import java.util.* ;


public class SigTest {

   public static void main ( String args[] ){

     try {


        while ( true ) {

           Date current = new Date () ; /*  current date */
           PrintWriter  fout
             = new PrintWriter( new FileWriter("SigTest.out", true), true );
                   /* out put file to monitor thread */

           fout.println( current.toString() ) ;
//         System.out.println( current.toString() ) ;
           fout.close() ;

           Thread.sleep(10000) ;

        }

     } catch ( Exception excp) {
         System.out.println( excp.toString() ) ;
     }

   }
}

4. Note 

  This does not happen with JDK1.2.2_008
     H:\sigtest>java -version
     java version "1.2.2"
     Classic VM (build JDK-1.2.2_008, native threads, symcjit)


2002-02-18
===============================================================================

Comments
WORK AROUND Using -Xrs option. At least the service process does not stop with log off although we can not get trace infomation with ctl + break key. (this side-effect might not be acceptable for some user.) 2002-02-18 ============================================================================ One way to be able to Ctrl+Break a service process is to write your own launcher, and after creating the vm, SetConsoleCtrlHandler() a handler which returns TRUE for CTRL_LOGOFF_EVENT, but returns FALSE for CTRL_BREAK_EVENT. http://www.kcmultimedia.com/javaserv/ provides such a launcher (including source code). ###@###.### 2003-04-22
22-04-2003

EVALUATION Sounds like a duplicate. ###@###.### 2002-02-20 Please see bug 4323062 for all the discussions on this issue. One possibility to support CTRL-BREAK for NT-Service is to add a command line option so that VM knows it is running as a service. An workaround is to use 3rd party debugger to obtain stack trace. ###@###.### 2002-03-01 When running java as a Windows service, -Xrs needs to be specified at the command line. With -Xrs, the testcase works fine. Close as not a bug. ###@###.### 2003-04-22
01-03-2002