Index: branches/simulator/projects/simulator/libsim/libsim.c
===================================================================
--- branches/simulator/projects/simulator/libsim/libsim.c	(revision 985)
+++ branches/simulator/projects/simulator/libsim/libsim.c	(revision 986)
@@ -1,6 +1,61 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <signal.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/shm.h>
+#include <sys/ipc.h>
+//#include <robot_shared.h>
+#include <string.h>
 
+
+//RobotShared* shared_state;
+
+void *tick(int sig)
+{
+  printf("robot process paused. suspending\n");
+
+  //shared_state->motor1++; 
+
+  if(raise(SIGTSTP)<0)
+    printf("could not kill self!\n");
+
+  printf("robot resumed\n");
+
+  return NULL;
+}
+
+
 void dragonfly_init(int config)
 {
+  struct itimerval iv;
+  int ret;
 
+  /*shared_state = shmat(atoi(envp[0]), NULL, 0);
+  if(shared_state < 0)
+  {
+	  printf("unable to get shared memory region\n");
+	  return 1;
+	  }*/
+
+                                             
+  printf("hello. I am a robot w/ memory_id %s\n", getenv("memory_id"));
+
+
+  iv.it_interval.tv_sec = 1;
+  iv.it_interval.tv_usec = 0;
+  iv.it_value.tv_sec = 3;
+  iv.it_value.tv_usec = 0;
+
+  signal(SIGVTALRM, tick);
+
+  ret = setitimer(ITIMER_VIRTUAL, &iv, NULL);
+
+  printf("setitimer returned %d.\n waiting...\n", ret);
+  fflush(stdout);
+
+  //TODO: clean up code??
+
 }
 
Index: branches/simulator/projects/simulator/simulator/robot_test/robot.c
===================================================================
--- branches/simulator/projects/simulator/simulator/robot_test/robot.c	(revision 985)
+++ branches/simulator/projects/simulator/simulator/robot_test/robot.c	(nonexistent)
@@ -1,63 +0,0 @@
-#include <stdio.h>
-#include <sys/time.h>
-#include <signal.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/shm.h>
-#include <sys/ipc.h>
-#include <robot_shared.h>
-#include <string.h>
-
-volatile int i;
-
-RobotShared* shared_state;
-
-void *tick(int sig)
-{
-  printf("robot process paused. suspending\n");
-
-  shared_state->motor1++; 
-
-  if(raise(SIGTSTP)<0)
-    printf("could not kill self!\n");
-
-  printf("robot resumed\n");
-
-  return NULL;
-}
-
-int main(int argc, char *argp[], char *envp[])
-{
-  int ret;
-  struct itimerval iv;
-
-  shared_state = shmat(atoi(envp[0]), NULL, 0);
-  if(shared_state < 0)
-  {
-	  printf("unable to get shared memory region\n");
-	  return 1;
-  }
-
-                                             
-  printf("hello. I am a robot w/ env[0] %s\n", envp[0]);
-
-  iv.it_interval.tv_sec = 1;
-  iv.it_interval.tv_usec = 0;
-  iv.it_value.tv_sec = 3;
-  iv.it_value.tv_usec = 0;
-
-  signal(SIGVTALRM, tick);
-
-  ret = setitimer(ITIMER_VIRTUAL, &iv, NULL);
-
-  printf("setitimer returned %d.\n waiting...\n", ret);
-  fflush(stdout);
-
-  i=0;
-
-  while(1)
-    i++;
-
-  shmdt(shared_state); 
-  return 0;
-}
Index: branches/simulator/projects/simulator/simulator/core/main.c
===================================================================
--- branches/simulator/projects/simulator/simulator/core/main.c	(revision 985)
+++ branches/simulator/projects/simulator/simulator/core/main.c	(revision 986)
@@ -13,11 +13,11 @@
 int create_robot(char *execname, int id, SimulatorRobot* sim_memory)
 {
   /* do shared memory stuff here */
-  key_t key = IPC_PRIVATE;
+  // key_t key = IPC_PRIVATE;
   /*Memory accessible only to children and gives them read/write priveledge*/
-  sim_memory->robotSharedMemoryID = shmget(key, sizeof(RobotShared), IPC_CREAT | 0666);
+  //  sim_memory->robotSharedMemoryID = shmget(key, sizeof(RobotShared), IPC_CREAT | 0666);
   
-  if(sim_memory->robotSharedMemoryID < 0)
+  /*  if(sim_memory->robotSharedMemoryID < 0)
   {
 	  printf("error getting shared memory\n");
 	  return -1;
@@ -30,11 +30,10 @@
 	printf("error attaching parent process\n");
 	return -1;
   }
-  
+  */
   /*Init robot structure here*/
-  sim_memory->robotState->motor1 = 0;
-  sim_memory->robotState->motor2 = 0;
-
+  /*  sim_memory->robotState->motor1 = 0;
+      sim_memory->robotState->motor2 = 0;*/
   int pid;
 
   if((pid = fork())<0){
@@ -43,7 +42,6 @@
   }                       
   
   char var[21];
-  sprintf(var, "memory_id=%d", sim_memory->robotSharedMemoryID);
   char *envp[] = {var, NULL};
 
   if(!pid){
@@ -50,6 +48,8 @@
     /* restore default sigchld handler */
     signal(SIGCHLD, SIG_DFL);
 
+    sprintf(var, "memory_id=%d", 1);//sim_memory->robotSharedMemoryID);
+
     execve(execname, NULL, envp);  //TODO: keep the other env. stuff around
     printf ("error! exec failed\n");
 	
@@ -61,8 +61,9 @@
 
 int free_robot(SimulatorRobot sim)                       
 {
-	shmdt(sim.robotState);
-	return shmctl(sim.robotSharedMemoryID, IPC_RMID, NULL); 
+  return 0;/*
+ 	shmdt(sim.robotState);
+	return shmctl(sim.robotSharedMemoryID, IPC_RMID, NULL); */
 }
 
 void *sig_chld_handler(int sig)
@@ -85,15 +86,20 @@
 {
   signal(SIGCHLD, sig_chld_handler);
 
-  SimulatorRobot sim;
+  //SimulatorRobot sim;
 
-  create_robot("robot_test/robot", 0, &sim);
+  if(argc<=1){
+    printf("Usage: simulator <robot execetuable>\n");
+    exit(-1);
+  }
 
+  create_robot(argv[1], 0, NULL/*&sim*/);
+
   printf("returned to parent\n");
 
   int x;
-  for(x = 0; x <10000; x++)
-	  printf("motor 1: %d\n", x);
+  /*  for(x = 0; x <10000; x++)
+      printf("motor 1: %d\n", x);*/
 
   gtk_gui_run(argc, argv);
 
Index: branches/simulator/projects/simulator/core/test_timer.c
===================================================================
--- branches/simulator/projects/simulator/core/test_timer.c	(revision 985)
+++ branches/simulator/projects/simulator/core/test_timer.c	(revision 986)
@@ -2,9 +2,11 @@
 #include <sys/time.h>
 #include <signal.h>
 
+volatile int i;
+
 void *tick(int sig)
 {
-  printf("tick\n");
+  printf("tick. i=%d\n", i);
   fflush(stdout);
 
   return NULL;
@@ -27,7 +29,10 @@
   printf("setitimer returned %d.\n waiting...\n", ret);
   fflush(stdout);
 
-  while(1);
+  i=0;
 
+  while(1)
+    i++;
+
   return 0;
 }
