<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>InsaneDevelopers &#187; debug</title>
	<atom:link href="http://insanedevelopers.net/tag/debug/feed/" rel="self" type="application/rss+xml" />
	<link>http://insanedevelopers.net</link>
	<description>My personal trash bin</description>
	<lastBuildDate>Mon, 26 Dec 2011 11:00:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Application monitoring</title>
		<link>http://insanedevelopers.net/2009/03/13/application-monitoring/</link>
		<comments>http://insanedevelopers.net/2009/03/13/application-monitoring/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 23:49:02 +0000</pubDate>
		<dc:creator>Alessandro</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[debug api]]></category>

		<guid isPermaLink="false">http://insanedevelopers.net/?p=5</guid>
		<description><![CDATA[I&#8217;ve been asked if there&#8217;s a way to programmatically determine if an application crashed in order to restart it; the answer is, of course, yes. To accomplish this task, you have to create the process with a launcher that acts &#8230; <a href="http://insanedevelopers.net/2009/03/13/application-monitoring/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been asked if there&#8217;s a way to programmatically determine if an application crashed in order to restart it; the answer is, of course, yes. To accomplish this task, you have to create the process with a launcher that acts like a debugger; your application only needs to check the exit code of the process whenever it receives an EXIT_PROCESS_DEBUG_EVENT event (you can also check for unrecoverable exceptions).</p>
<p>Here&#8217;s the pseudo-code:</p>
<pre>DEBUG_EVENT deDebugEvent;
...
WaitForDebugEvent(..);
...
// Check the event type
switch(deDebugEvent.dwDebugEventCode)
{
	...
	case EXIT_PROCESS_DEBUG_EVENT:
	{
		// We assume that if the program exited with a nonzero code, it crashed
		if (deDebugEvent.u.ExitProcess.dwExitCode)
		{
			// The program crashed
			DebugActiveProcessStop(...);
			CreateProcess(...);
			...
		}

		// Clean exit
		ExitProcess(0);
	}
	...
}</pre>
<p>Source code: <a href="http://www.insanedevelopers.net/downloads/Sources/ApplicationMonitor.zip">http://www.insanedevelopers.net/downloads/Sources/ApplicationMonitor.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://insanedevelopers.net/2009/03/13/application-monitoring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

