Changeset 341 for trunk/openjdk/jdk


Ignore:
Timestamp:
Mar 8, 2012, 2:46:46 PM (13 years ago)
Author:
dmik
Message:

jdk: Create JVM on main thread in Java executables on OS/2.

This fixes hangs at crashes when the Java process is killed
externally by Ctrl-C or by a kill signal (#33 and #159).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/openjdk/jdk/src/share/bin/java.c

    r333 r341  
    5858#include <string.h>
    5959
     60#ifdef __OS2__
     61#include <float.h> // for _control87
     62#endif
     63
    6064#include <jni.h>
    6165#include <jvm.h>
     
    368372      args.ifn = ifn;
    369373
     374#ifdef __OS2__
     375      // On OS/2, both Ctrl-C and process termination handlers (including DLL
     376      // uninitialization code) are always called on thread 1. If we fire off
     377      // a new thread here and create the JVM on it (as other platfroms do),
     378      // thread 1 will be not known to the JVM and this can cause various
     379      // nexpected side-effects like hangs and crashes at Java process
     380      // termination (see #33 and #159 for details). For this reason, we instead
     381      // create the JVM right on thread 1.
     382
     383      // disable FPU exceptions (taken from jdk/src/windows/hpi/src/system_md.c)
     384      _control87(MCW_EM | RC_NEAR | PC_53, MCW_EM | MCW_RC | MCW_PC);
     385
     386      return JavaMain(&args);
     387#else
    370388      return ContinueInNewThread(JavaMain, threadStackSize, (void*)&args, ret);
     389#endif
    371390    }
    372391}
Note: See TracChangeset for help on using the changeset viewer.