diff --git a/platform/cooja/lib/simEnvChange.c b/platform/cooja/lib/simEnvChange.c
index a0b918d19..d13e208a4 100644
--- a/platform/cooja/lib/simEnvChange.c
+++ b/platform/cooja/lib/simEnvChange.c
@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Id: simEnvChange.c,v 1.3 2006/10/05 12:09:53 fros4943 Exp $
+ * $Id: simEnvChange.c,v 1.4 2006/10/06 10:47:09 fros4943 Exp $
  */
 
 #include <stdio.h>
@@ -38,6 +38,7 @@
 extern const struct simInterface *simInterfaces[];
 
 char simDontFallAsleep = 0;
+char simInsideProcessRun = 0;
 
 int simProcessRunValue;
 int simEtimerPending;
diff --git a/platform/cooja/lib/simEnvChange.h b/platform/cooja/lib/simEnvChange.h
index 9d55e329d..2461609d5 100644
--- a/platform/cooja/lib/simEnvChange.h
+++ b/platform/cooja/lib/simEnvChange.h
@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Id: simEnvChange.h,v 1.3 2006/10/05 12:09:53 fros4943 Exp $
+ * $Id: simEnvChange.h,v 1.4 2006/10/06 10:47:09 fros4943 Exp $
  */
 
 #ifndef __SIMENVCHANGE_H__
@@ -45,6 +45,7 @@ extern int simNextExpirationTime;
 
 // Variable that when set to != 0, stops the mote from falling asleep next tick
 extern char simDontFallAsleep;
+extern char simInsideProcessRun;
 
 // Definition for registering an interface
 #define SIM_INTERFACE(name, doActionsBeforeTick, doActionsAfterTick) \
diff --git a/tools/cooja/config/code_main_template b/tools/cooja/config/code_main_template
index a2ef72857..968f12f8d 100644
--- a/tools/cooja/config/code_main_template
+++ b/tools/cooja/config/code_main_template
@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Id: code_main_template,v 1.7 2006/10/05 12:10:12 fros4943 Exp $
+ * $Id: code_main_template,v 1.8 2006/10/06 10:47:33 fros4943 Exp $
  */
 
 /**
@@ -116,7 +116,9 @@ start_process_run_loop(void *data)
 		/* Always pretend we have processes left while inside process_run() */
 		simProcessRunValue = 1;
 
+		simInsideProcessRun = 1;
 		simProcessRunValue = process_run();
+		simInsideProcessRun = 0;
 
 		// Check if we must stay awake
 		if (simDontFallAsleep) {