Java program stopped running when using JVMPI

Hi!
I'm writting a very simple profiler using JVMPI. I intended to pause/continue it by sending signal, like kill -SIGUSR2 PID, to it, but whenever I did this, the java program that ran with the profiler stopped running, however the profiler kept running properly.
Here's the code of the simple profiler and the testing java program.
//myprofiler.cc
#include <jvmpi.h>
#include <pthread.h>
#include <stdio.h>
#include <signal.h>
void sig_handler_pause(int);
static JVMPI_Interface *jvmpi_interface;
void notifyEvent(JVMPI_Event *event) {
switch(event->event_type) {
case JVMPI_EVENT_CLASS_LOAD:
fprintf(stderr, "myprofiler> Class Load : %s\n", event->u.class_load.class_name);
break;
case JVMPI_EVENT_OBJECT_ALLOC:
fprintf(stderr, "myprofiler>object alloc \n");
break;
extern "C" {
JNIEXPORT jint JNICALL JVM_OnLoad(JavaVM jvm, char options, void *reserved) {
fprintf(stderr, "myprofiler> initializing ..... \n");
// get jvmpi interface pointer
if ((jvm->GetEnv((void **)&jvmpi_interface, JVMPI_VERSION_1)) < 0) {
fprintf(stderr, "myprofiler> error in obtaining jvmpi interface pointer\n");
return JNI_ERR;
// initialize jvmpi interface
jvmpi_interface->NotifyEvent = notifyEvent;
// enabling class load event notification
jvmpi_interface->EnableEvent(JVMPI_EVENT_CLASS_LOAD, NULL);
fprintf(stderr, "myprofiler> .... ok \n\n");
signal(SIGUSR2,sig_handler_pause);
return JNI_OK;
void start(){
          fprintf(stderr,"start...\n");
     jvmpi_interface->EnableEvent(JVMPI_EVENT_OBJECT_ALLOC, NULL);
jvmpi_interface->EnableEvent(JVMPI_EVENT_CLASS_LOAD,NULL);
void pause(){
          fprintf(stderr,"pause...\n");
          jvmpi_interface->DisableEvent(JVMPI_EVENT_OBJECT_ALLOC, NULL);
jvmpi_interface->DisableEvent(JVMPI_EVENT_CLASS_LOAD,NULL);
int status=0;
void sig_handler_pause(int sig){
     if(status == 0){
          start();
          status = 1;
     else if(status == 1){
          pause();
          status = 0;
//Test.java
public class Test {
public static void main(String[] args) {
     try {
                    int i = 0;
while(true)
                         Thread.sleep(1000);
                    System.out.println(i++);
          catch (Exception e) {
                    e.printStackTrace();
Here're some notes:
1)If I didn't call
jvmpi_interface->EnableEvent(JVMPI_EVENT_OBJECT_ALLOC, NULL);
in "start()" function, the java program Test ran properly after I sent signal to the process by using kill command in an command line;
or
2) If I delete "Thread.sleep(1000)" in Test.java, then whether I call
jvmpi_interface->EnableEvent(JVMPI_EVENT_OBJECT_ALLOC, NULL);
in "start()" or not, the Test program ran properly after I sent signal to the process.
It seems to be a thread dead lock, but I'm not sure. Can any body help?Thanks very much.

I should strongly recommend moving from JVMPI to JVM TI if you can. The reason is that JVMPI has been deprecated since 5.0 and can not be used with Java SE 6 and newer.
Anyway, the issue you have may be due to the signal you are using. I'm not sure which operating system this is but on Linux the USR2 signal is used for the suspend/resume implementation. Have you looked at the Troubleshooting Guide or the Signal Chaining page for details on how signals are used and how to chain handlers? Another idea is to remove the signal handling code implementation and to use the data dump event. This is supported by both JVMPI and JVM TI so that you get an event (via the QUIT signal).

Similar Messages

  • How to do "java Program 50 7" when using Eclipse?

    If you use the command-line environment to compile and run a java program called Sample.java instead of using Eclipse, you could compile by writing "java Sample 30 5" or replace the 30 and 5 with other numbers (lets suppose the Sample.java needs 2 int inputs). How would you do the equivalent of that when using Eclipse?
    Thanks!

    In the Run , there is an arguments tab ..

  • Why don't java applets run when using Firefox 4.0 in a windows limited user account?

    Java applications will not run in Firefox 4.0 when the windows user/process only has limited user access rights. The systems, I see this behaviour on have Windows XP Pro SP3, Firefox 4.0 and JRE 1.6.0_24 installed. The java application will run when when full administrative rights are present. This issue did not occur with the 3.6 firefox version that was previously installed.

    The problem also exists with the newer Firefox 4.0.1 and Java 1.6.0_25 versions.
    Enabling administrative rights resolves the issue ... though this defeats the purpose of using a limited user.
    The underlying bug appears to be in the Firefox java plugin detection code. The issue is related to the detection code requiring write access to the HKLM\SOFTWARE\mozilla.org windows registry key. The limited user only has read access for this registry key. The behaviour was identified using the Sysinternals ProcessMonitor utility ... showed firefox calling an interface to create the registry key and getting an access denied response in the limited user case.
    A more targeted workaround for the issue is to grant the limited user write access on the HKLM\SOFTWARE\mozilla.org windows registry key. This avoids the need to grant administrative rights to the user and enables the java plugin to be detected. That is, it works on the 2 XP systems where the java plugin wasn't being detected in limited user accounts.

  • Elements 11 program stops working when photo collage opened when 297 x 210 selected

    Adobe Photoshop elements 11 program stops working when photo collage opened when 297 x 210 selected>Running Windows 8.1

    Hi Jane
    There are sometimes problems calling up the template from the media database. Why not design your own? It is possible to make a collage manually in Expert Mode and its quite easy.
    Click File >> Open and select all of your photos
    That will add them to the project bin
    Then select File >> New >> Blank File
    Select background color White (or whatever you prefer) and add your width and height for your final image (set resolution 72 for web usage or 240 to 300 for printing) then click OK
    In the project bin click your first photo and drag it up into the main window on top of your new background.
    Click on the move tool and click in the center of the photo and drag to arrange it where you want on the background - you can hold down the shift key to maintain original proportions whilst dragging the corner handles of the bounding box to get the size you want.
    Do the same with the next photo (drag it up into the main window) and use the move tool to position it. Then continue with each image.
    Finally Click Layer >>Flatten image and save as jpeg. (Save as PSD if you want to preserve the layers for editing again)
    N.B. as you add images they get dropped in the center. So you need to use the move tool to drag them apart. Click in the middle of one and move it around, and then the others until you get them positioned as you want.
    When you click again with the move tool a bounding box appears around the image and you can drag out the corner handles to re-size your photos. Hold down the shift key when dragging the corner handle and that will maintain the proportions of the original.
    Finally click Layer >>Flatten Image and save your collage - you may then want to use the crop tool to cut away any surplus white canvas, and then re-save.

  • Can a java program be run in the background?

    Hi all,
    Can a java program be run in the background without the user being aware of it? I need to make a program that continuosly monitors a pc at regular intervals and runs at all time. It should be hidden(shouldn't display on the screen while running) from the user, and also, can it be run as a system file so that even if a user checks he/she would think of it as a system file?

    I'm the administrator of all the computers. Then as I said there are commercial applications that do that.
    Presumably you expect a problem now. And implementing an acceptable solution is going to take you months. Because not only need to 'hide' the application, you also need to set up all the monitoring and logging capability. And the first will require quite a bit of JNI work along with testing (in particular as it could interfer with existing applications on the users computers.)
    I need to
    install the software in all the machines and i want
    that the users who use the machine should not be able
    to close the program through the task manager. If the users have admin rights then they can terminate a windows service.
    And if they don't have admin rights then you can simply turn off the ability to install anything.
    I want
    to know what the resources of the computers are and
    that if anyone has added a resource to it or
    not(attaching a flash usb thumbdrive etc). Lots of JNI.

  • How can java programs execute automatically when it connects to network

    Good Day dears...
    How can java programs execute automatically when it connects to network.
    Thanks in Advance friends Shackir

    884924 wrote:
    Good Day dears...
    How can java programs execute automatically when it connects to network.What is "it"? That is, execute when what connects to the network?
    Your computer? If that's what you mean, this is not a Java question. It's an OS operational/administrative question. Executing any program, whether written in Java or not, based on some system event has to do with that system, not with the program. If it's possible to do this, you'd do it exactly the same way for a Java program as you would for any other program.
    Or is "it" the program itself? If this is what you mean, then it's a nonsensical question. For the program to connect to the network and detect that it has connected to the network, it must already be executing, so asking how to execute it at that point is meaningless.
    Finally, I'll point out that "connecting to the network" is a pretty meaningless phrase. Or rather, it has so many potentially valid meanings that it's impossible to know which one you're referring to when you use that phrase. And I'd be willing to bet you don't have a clear picture of that yourself.

  • Why did my CS4 Stop Running When I Installed a Trial Version of Elements?

    Why did my Adobe CS4 Stop Running When I Installed a Trial Version of Elements?
    I cannot use any of my purchased Adobe CS4 products.  I installed a trial version of Elements and none of my licensed CS4 components will run.  Please help.

    So let me be sure I understand:
    You can open Photoshop normally as it was before you saw the trial version?
    Bridge CS6 opens, but you cannot see your pictures?  Here's an easy way to check:
    First reboot your computer. Photoshop CS6 should open normally, that way we know it's fixed.  You can exit Photoshop
    Now...
    Make a shortcut to Bridge CS6 and place it on your desktop.
    From Windows Explorer, drag one of your picture folders to the Bridge shortcut.
    Bridge should open and show the pictures in your folder.
    If it does not, get back to me and we will look at other ideas.
    Gene

  • Why my 2013 Retina MacBook pro aways stop running when it startup

    why my 2013 Retina MacBook pro aways stop running when it startup?
    I try to reset smc and pram .
    but its no work. howhow can I check what happy in my rmbp?

    The startup disk may need repairing ..
    Startup your Mac while holding down the Command + R keys so you can access the built in utilities in OS X to repair the startup disk and reinstall OS X  using OS X Recovery

  • Executable does not stop running when closed

    I am trying to build an executable, but it does not stop running when I quit. I have to stop it through the task manager. How can I make it actually stop the .exe thread?
    I have confirmed that the loop stops running, and have even tried connecting it to the "stop" function.
    Thank you!

    Jeff Bohrer wrote:
    Ahh-
    emc08 wrote:
    It is done in the "Quit" case of the user events.
    But you left the right side tunnel unwired from the the inside (so the event reg terminal OUT contains the valid refnum to the user event you just tried to destroy)  Event terminals behave like SRs with invisable wires in every case that is not wired
    Here is an example demoing just this behavior.
    I'm sorry, but I can't see th eexample because I am running 2009. I think I understand. I've cleaned up the code a little bit, and added a shift register for the events. Is this what I needed to do? This still does not solve the problem, unfortunately. If I close, the "Quit" sequence properly executes, (including closing of the front panel), but the thread still does not close.
    Attachments:
    Program.vi ‏218 KB

  • HT4864 My outgoing email as stopped working when using Outlook for mac 2011. Any suggestions?

    My outgoing email as stopped working when using Outlook for mac 2011. I have deleted and reinstalled the account twice. I have 11 gig free on my iCloud account. The outgoing server is set at smtp.mail.me.com using port 587. If I was able to reinstall the account, I am positive I have the correct password. I can log into my iCloud accout using the same credentials.
    Any suggestions?

    I called Microsoft to fix my problem...for those maybe having the same issue, I was told by the Tech to use this outgoing server setting - p06-smtp.mail.me.com
    All is working fine since doing so.

  • Open connections between AS Java and AS ABAP when using JRA

    Hi, we have a problem with open connections and hope that someone here could give me hint where to find a solution.
    The situation is that we open a connection from a Java application to an AS ABAP. In detail, the application first connects to a statefull session bean on the AS Java by RMI. The bean communicates with the associated AS ABAP by the Java Resource Adapter (JRA).
    All interactions between all components work correctly. But even after we close the application, manually close of the connections (on side of the AS Java) , remove all created and used session beans there are still open connections between the AS ABAP and the AS Java.
    The transaction smgw (Gateway Monitor) shows open connections from jlaunch to our local SAP gateway using the internal communication protocol. Obviously, the established connections are not closed, even when they are open for a week or longer.
    After opening 100 connections, the AS ABAP denies additional connection attempts.
    We have been able to close all open connections by restarting the AS Java or by restarting the Connector over the Visual Administrator (path: Cluster – Server – Services – Connector Container – “select the right connector” – stop / start).
    We have developed our application similar to the tutorial from [https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/ad09cd07-0a01-0010-93a9-933e247d3ba4]
    Can someone explain to us why the connections stay open for so long? Is there no timeout mechanism? Or is there some way to close the connections from our Java application?

    Hello,
    maybe someone can help us with our problem.
    We have developed our application similar to the tutorial from https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/ad09cd07-0a01-0010-93a9-933e247d3ba4 and it was running without problem with the SP12, now we change our system to SP16 and we are having the problem described in note 1083348, but as you can see, for us it was working with SP12 and now it doesn't work with SP16....
    Here is part of our code....
        public List getAll() {
            String functionName = "bla";
            try {
                openConnection();
                MappedRecord response = (MappedRecord) interaction.execute(null, request);
                MappedRecord record = (MappedRecord) response.get("E_S_RETURN_CODE");
                if (((String) record.get("RETURN_CODE")).equalsIgnoreCase("E")) {
                    throw new SQLException((String) record.get("RETURN_TXT"));
            catch (ResourceException exc) {
                throw new EJBException(".");
            catch (SQLException exc) {
                throw new EJBException(".");
            finally {
                closeConnection();
        protected void openConnection() {
            try {
                connection = connectionFactory.getConnection();
                interaction = connection.createInteraction();
            catch (ResourceException exc) {
                interaction = null;
                connection = null;
                throw new EJBException(getExceptionText(exc));
      protected void closeConnection() {
           try {
                if (interaction != null) {
                    interaction.close();
                if (connection != null) {
                    connection.close();
            catch (ResourceException exc) {
                throw new EJBException(".");
    With that code we are getting this error: "Connection handle is already closed and no longer associated with a managed connection" everytime we try to close the connection in the method closeConnection().
    We were thinking that maybe we should not close the connections, because the were already close, and tried not to close the connection (connection.close()), but then after a few time we are getting the following error, because we are not closing the connections:
    Connection to ABAP System could not be opened, because the Connection Factory returns "Cannot get connection for 120 seconds. Possible reasons: 1) Connections are cached within SystemThread(can be any server service or any code invoked within SystemThread in the SAP J2EE Engine), 2) The pool size of adapter "eis/..." is not enough according to the current load of the system or 3) The specified time to wait for connection is not enough according to the pool size and current load of the system. In case 1) the solution is to check for cached connections using the Connector Service list-conns command, in case 2) to increase the size of the pool and in case 3) to increase the time to wait for connection property. In case of application thread, there is an automatic mechanism which detects unclosed connections and unfinished transactions.". Please check the connection defined for the Connection Factory of the Java Resource Adapter with JNDI name...
    Any help?

  • Java Program Not Running

    Hi,
    I have a small Java program that imports Oracle.sql.* and Oracle.jdbc.*.
    It establishes a default connection and converts a String[ ] to Oracle.sql.ARRAY type.
    As per Oracle documentation, I have added paths of required .zip files in CLASSPATH variable.
    Though I am able to compile the code, but when I try to run it thru java, it gives me error:
    Exception in Thread "main" java.lang.NoClassDefFoundError: TestInstallJDBC
    The .java and .class files are in current directory and I'm using
    java TestInstallJDBC.
    What can be the problem?
    Any help is appreciated.
    Thanks

    Ah, I re-read your first post - you said you added paths to the Classpath. So you need to add . to your Classpath as well. For Windows .;<existing_classpath> or for Unix .:<existing_classpath>

  • Java program shuts down when I close Terminal.

    I use following:
    Java: 1.3.1_01
    Platform: Solaris
    Shell: bourn
    I've a java program in which, I've implemented shutdown hooks (Runtime.addshutdownhook()) for proper shut down of my application.
    I've a shell script to start & stop this application.
    Now, if I use bourn shell to start this app, when I close the terminal window, the program also shuts down.
    I tried using 'nohup' command but its not working. I also tried starting it in background by appending '&'. It is not working either.
    Can someone pls give me solution?
    - Samir

    I don't think there is a solution to your problem (other than not to close the terminal window) because according to the documentation:
    addShutdownHook
    public void addShutdownHook(Thread hook)
    Registers a new virtual-machine shutdown hook.
    The Java virtual machine shuts down in response to two kinds of events:
    1) The program exits normally, when the last non-daemon thread exits or when the exit (equivalently, System.exit) method is invoked, or
    2) The virtual machine is terminated in response to a user interrupt, such as typing ^C, or a system-wide event, such as user logoff or system shutdown.
    The behavior you described is consistent with what I see on my Windows 98SE.
    V.V.

  • ITunes stops running when trying to sync

    My replacement iphone will not sync all my apps music or phtos, itunes stops running on the computer.

    I have the same issue since I loaded one of the ITunes 11 updates - my IPhone 4s is running iOS 8.1 and now I'm running ITunes 12 - with no luck.  I update all of the apps and when ITunes gets to Step 6 of 6 and tries to copy the update to my phone, I get an error that ITunes has stopped working and a problem caused the program to stop working correct.  I have to close the program. 
    Is there anyway I can get these updates to work so I don't have to use my data plan to update my apps??

  • Voicemail showing as "has stopped working" when using MRA & SSO via Expressway 8.5.1

    Hello Everyone,
    I have my Mac connected to our CallManager via Expressway 8.5.1 MRA using SAML SSO using Jabber Version 10.6.0 (202336).
    Our CallManager, IM&P and Unity Connection Servers are all 10.5.2
    My issue is that Voicemail shows as "has stopped working". It does not do this for SSO users who are not using MRA.
    If I disable SSO it works fine (username/password on Jabber starup and same username/password on Voicemail login page once connected)
    I have not yet tested if Jabber for Windows is affected when using MRA via Expressway.
    UPDATE: This issue affects Jabber for iOS as well with the same error
    I have a Problem Report from the machine if required.
    Any help you can provide will be appreciated.
    Many Thanks,
    Brian Skelly

    Please,  run the DirectX diagnostics tool. Go to Windows Start  and in the Run box type dxdiag.exe and press the OK button. This will start the DirectX diagnostics program. Run this diagnostics and save the results to a file. Please, attach this file to your post. Be aware that you will have to zip this file before attaching it here.

Maybe you are looking for

  • 'NI-PAL Service Manager has encountered a problem and needs to close. We are sorry for the inconvenience.'

    Hello, Any idea how to fix this problem that casuses this error? 'NI-PAL Service Manager has encountered a problem and needs to close. We are sorry for the inconvenience.' I have been re-loading LabVIEW 8.0.1 Pro Dev Sytem, NI-DAQ (Traditional) and N

  • Purchase order print ID for  condition lines

    How to add / remove  condition types ie. freight rates, handling charges in purchase order print out ?. i want the values of these condition types to be /not to be in the purchase order print out. even when i m maintaining these values in P.0 conditi

  • Can OS X Tiger be purchased on CD-ROM

    my PowerMac g3 which I would like to upgrade only has a cd rom drive. I have os x tiger on DVD and I think apple only made it on DVD. did apple ever make it as a cd version?

  • Macbook Pro Wifi

    whenever i have my macbook on my leg while using it from some reason the wifi stops working and i cannot turn it on one more time im guessing it overheated and i went to apple store beside me and when they run the diagnose they find everything looks

  • Should I upgrade to Lion?

    I have a Macbook, 2.4GHz processor with 2 GB memory, currently running Leopard. Ever since Lion came out, I have been going back and forth whether I should upgrade my Macbook or not. Because I have been hearing many problems/inconvenience (?) of the