<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: If JNI based application is crashing, check signal handling!</title>
	<atom:link href="http://javajiggle.com/2008/01/06/if-jni-based-application-is-crashing-check-signal-handling/feed/" rel="self" type="application/rss+xml" />
	<link>http://javajiggle.com/2008/01/06/if-jni-based-application-is-crashing-check-signal-handling/</link>
	<description>Java Jiggle. See what's shaking.</description>
	<lastBuildDate>Tue, 10 Apr 2012 03:35:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: DLL accessed via JNI terminates App Server running as Windows Service when Logoff of RDP Console &#124; SeekPHP.com</title>
		<link>http://javajiggle.com/2008/01/06/if-jni-based-application-is-crashing-check-signal-handling/comment-page-1/#comment-14564</link>
		<dc:creator>DLL accessed via JNI terminates App Server running as Windows Service when Logoff of RDP Console &#124; SeekPHP.com</dc:creator>
		<pubDate>Wed, 12 Oct 2011 23:01:48 +0000</pubDate>
		<guid isPermaLink="false">http://javajiggle.com/2008/01/06/if-jni-based-application-is-crashing-check-signal-handling/#comment-14564</guid>
		<description>[...] JavaJiggle Article on Signal Handling [...]</description>
		<content:encoded><![CDATA[<p>[...] JavaJiggle Article on Signal Handling [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DLL accessed via JNI terminates App Server running as Windows Service when Logoff of RDP Console &#124; trouble86.com</title>
		<link>http://javajiggle.com/2008/01/06/if-jni-based-application-is-crashing-check-signal-handling/comment-page-1/#comment-14533</link>
		<dc:creator>DLL accessed via JNI terminates App Server running as Windows Service when Logoff of RDP Console &#124; trouble86.com</dc:creator>
		<pubDate>Sun, 09 Oct 2011 23:18:58 +0000</pubDate>
		<guid isPermaLink="false">http://javajiggle.com/2008/01/06/if-jni-based-application-is-crashing-check-signal-handling/#comment-14533</guid>
		<description>[...] http://javajiggle.com/2008/01/06/if-jni-based-application-is-crashing-check-signal-handling/ [...]</description>
		<content:encoded><![CDATA[<p>[...] <a href="http://javajiggle.com/2008/01/06/if-jni-based-application-is-crashing-check-signal-handling/" rel="nofollow">http://javajiggle.com/2008/01/06/if-jni-based-application-is-crashing-check-signal-handling/</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: raja</title>
		<link>http://javajiggle.com/2008/01/06/if-jni-based-application-is-crashing-check-signal-handling/comment-page-1/#comment-12306</link>
		<dc:creator>raja</dc:creator>
		<pubDate>Tue, 12 Apr 2011 19:14:28 +0000</pubDate>
		<guid isPermaLink="false">http://javajiggle.com/2008/01/06/if-jni-based-application-is-crashing-check-signal-handling/#comment-12306</guid>
		<description>Hi,

what is the use of CheckJni flag?. If we dont set it in our code, then native singals still collide with JVM signals?</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>what is the use of CheckJni flag?. If we dont set it in our code, then native singals still collide with JVM signals?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: javajiggle</title>
		<link>http://javajiggle.com/2008/01/06/if-jni-based-application-is-crashing-check-signal-handling/comment-page-1/#comment-2049</link>
		<dc:creator>javajiggle</dc:creator>
		<pubDate>Wed, 08 Jul 2009 23:58:21 +0000</pubDate>
		<guid isPermaLink="false">http://javajiggle.com/2008/01/06/if-jni-based-application-is-crashing-check-signal-handling/#comment-2049</guid>
		<description>Mehul, 
just got back from my vacation.  Let me try to answer your questions. 
1. signal(SIGINT,mySigHandler) or simply using signal from handler function seems not allowed by g++ compiler … any idea why ? 
&gt; I&#039;m not sure what you mean.   Did you include the signal.h?  see included sample below. 

2. how does signal chaining help for handling native code related issues which can raise signal ? 
&gt;If the native code uses signals and creates the JVM, the JVM will override the signal handler in the native code.   The signal chaining allows JVM to determine whether a raised signal was intended for it.   

I believe that in native code, if two or more libraries use the same signals it is possible that at least one of the signal handlers will be overridden.   Thus signal chaining can be used to ensure that the signals are properly dispatched to the right handlers.    If I&#039;m correct, it can be done by first loading a library that will store signal handlers when libraries register their signal handlers.   It will then dispatch signals to the right signals handlers.   This means that the dispatching library must be loaded first, before libraries that implement signal handlers are loaded.

Here is an example (jsig.c) implementation. 
http://xref.jsecurity.net/openjdk-6/langtools/d3/dae/solaris_2vm_2jsig_8c-source.html

3. can we have more insight on 3rd approach of using LD_PRELOAD? 
&gt;LD_PRELOAD simply specifies libraries that must be loaded before other libraries are loaded.   This avoids a need to link with the library that stores and dispatches to the signal handlers.

Signal example:
-----------------------------------------------
#include &lt;signal.h&gt;
#include &lt;stdio.h&gt;
#include &lt;unistd.h&gt;

void handler( int sig ){
	printf(&quot;signal handler invoked, signal: %d \n&quot;, sig );
}

int main(){
	signal( SIGINT, handler );
	printf(&quot;test SIGINT\n&quot;);
	while( 1 ){
		sleep(1000);
	}
	return 1;
}</description>
		<content:encoded><![CDATA[<p>Mehul,<br />
just got back from my vacation.  Let me try to answer your questions.<br />
1. signal(SIGINT,mySigHandler) or simply using signal from handler function seems not allowed by g++ compiler … any idea why ?<br />
> I&#8217;m not sure what you mean.   Did you include the signal.h?  see included sample below. </p>
<p>2. how does signal chaining help for handling native code related issues which can raise signal ?<br />
>If the native code uses signals and creates the JVM, the JVM will override the signal handler in the native code.   The signal chaining allows JVM to determine whether a raised signal was intended for it.   </p>
<p>I believe that in native code, if two or more libraries use the same signals it is possible that at least one of the signal handlers will be overridden.   Thus signal chaining can be used to ensure that the signals are properly dispatched to the right handlers.    If I&#8217;m correct, it can be done by first loading a library that will store signal handlers when libraries register their signal handlers.   It will then dispatch signals to the right signals handlers.   This means that the dispatching library must be loaded first, before libraries that implement signal handlers are loaded.</p>
<p>Here is an example (jsig.c) implementation.<br />
<a href="http://xref.jsecurity.net/openjdk-6/langtools/d3/dae/solaris_2vm_2jsig_8c-source.html" rel="nofollow">http://xref.jsecurity.net/openjdk-6/langtools/d3/dae/solaris_2vm_2jsig_8c-source.html</a></p>
<p>3. can we have more insight on 3rd approach of using LD_PRELOAD?<br />
>LD_PRELOAD simply specifies libraries that must be loaded before other libraries are loaded.   This avoids a need to link with the library that stores and dispatches to the signal handlers.</p>
<p>Signal example:<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
#include <signal .h><br />
#include <stdio .h><br />
#include <unistd .h></p>
<p>void handler( int sig ){<br />
	printf(&#8220;signal handler invoked, signal: %d \n&#8221;, sig );<br />
}</p>
<p>int main(){<br />
	signal( SIGINT, handler );<br />
	printf(&#8220;test SIGINT\n&#8221;);<br />
	while( 1 ){<br />
		sleep(1000);<br />
	}<br />
	return 1;<br />
}</unistd></stdio></signal></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Klassen</title>
		<link>http://javajiggle.com/2008/01/06/if-jni-based-application-is-crashing-check-signal-handling/comment-page-1/#comment-2048</link>
		<dc:creator>David Klassen</dc:creator>
		<pubDate>Wed, 08 Jul 2009 23:47:19 +0000</pubDate>
		<guid isPermaLink="false">http://javajiggle.com/2008/01/06/if-jni-based-application-is-crashing-check-signal-handling/#comment-2048</guid>
		<description>You are a pioneer my friend. Thanks for paving the way to a proof my code is not the culprit of the JVM crash.</description>
		<content:encoded><![CDATA[<p>You are a pioneer my friend. Thanks for paving the way to a proof my code is not the culprit of the JVM crash.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mehul Parekh</title>
		<link>http://javajiggle.com/2008/01/06/if-jni-based-application-is-crashing-check-signal-handling/comment-page-1/#comment-1901</link>
		<dc:creator>Mehul Parekh</dc:creator>
		<pubDate>Fri, 03 Jul 2009 05:19:41 +0000</pubDate>
		<guid isPermaLink="false">http://javajiggle.com/2008/01/06/if-jni-based-application-is-crashing-check-signal-handling/#comment-1901</guid>
		<description>3 questions.
1) signal(SIGINT,mySigHandler) or simply using signal from handler function seems not allowed by g++ compiler ... any idea why ?
2) how does signal chaining help for handling native code related issues which can raise signal ?
3) can we have more insight on 3rd approach of using LD_PRELOAD?</description>
		<content:encoded><![CDATA[<p>3 questions.<br />
1) signal(SIGINT,mySigHandler) or simply using signal from handler function seems not allowed by g++ compiler &#8230; any idea why ?<br />
2) how does signal chaining help for handling native code related issues which can raise signal ?<br />
3) can we have more insight on 3rd approach of using LD_PRELOAD?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sumit Kumar</title>
		<link>http://javajiggle.com/2008/01/06/if-jni-based-application-is-crashing-check-signal-handling/comment-page-1/#comment-1642</link>
		<dc:creator>Sumit Kumar</dc:creator>
		<pubDate>Wed, 24 Jun 2009 05:49:33 +0000</pubDate>
		<guid isPermaLink="false">http://javajiggle.com/2008/01/06/if-jni-based-application-is-crashing-check-signal-handling/#comment-1642</guid>
		<description>Clear and Concise! Excellent Work..</description>
		<content:encoded><![CDATA[<p>Clear and Concise! Excellent Work..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Java Jiggle</title>
		<link>http://javajiggle.com/2008/01/06/if-jni-based-application-is-crashing-check-signal-handling/comment-page-1/#comment-177</link>
		<dc:creator>Java Jiggle</dc:creator>
		<pubDate>Wed, 08 Apr 2009 21:49:46 +0000</pubDate>
		<guid isPermaLink="false">http://javajiggle.com/2008/01/06/if-jni-based-application-is-crashing-check-signal-handling/#comment-177</guid>
		<description>signal(SIGINT, mySigHandler); &lt;-- will register mySigHandler function as a handler for SIGINT.   I believe on some platforms you may need to re-register your signal handler or the default handler will be invoked with the next SIGINT.</description>
		<content:encoded><![CDATA[<p>signal(SIGINT, mySigHandler); &lt;&#8211; will register mySigHandler function as a handler for SIGINT.   I believe on some platforms you may need to re-register your signal handler or the default handler will be invoked with the next SIGINT.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Biswa</title>
		<link>http://javajiggle.com/2008/01/06/if-jni-based-application-is-crashing-check-signal-handling/comment-page-1/#comment-176</link>
		<dc:creator>Biswa</dc:creator>
		<pubDate>Wed, 08 Apr 2009 18:25:25 +0000</pubDate>
		<guid isPermaLink="false">http://javajiggle.com/2008/01/06/if-jni-based-application-is-crashing-check-signal-handling/#comment-176</guid>
		<description>void mySigHandler( int sig ){
	printf(&quot;mySigHandler received signal: %d \n&quot;, sig );
	signal(SIGINT, mySigHandler);---&gt; This does not look right rest understandable
}</description>
		<content:encoded><![CDATA[<p>void mySigHandler( int sig ){<br />
	printf(&#8220;mySigHandler received signal: %d \n&#8221;, sig );<br />
	signal(SIGINT, mySigHandler);&#8212;&gt; This does not look right rest understandable<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JoeK</title>
		<link>http://javajiggle.com/2008/01/06/if-jni-based-application-is-crashing-check-signal-handling/comment-page-1/#comment-104</link>
		<dc:creator>JoeK</dc:creator>
		<pubDate>Wed, 04 Feb 2009 22:23:20 +0000</pubDate>
		<guid isPermaLink="false">http://javajiggle.com/2008/01/06/if-jni-based-application-is-crashing-check-signal-handling/#comment-104</guid>
		<description>Best description on the web.   I&#039;m amazed how simple the solution is!   This should be better advertised on the sun&#039;s web site.</description>
		<content:encoded><![CDATA[<p>Best description on the web.   I&#8217;m amazed how simple the solution is!   This should be better advertised on the sun&#8217;s web site.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

