 +static int g_argc;
 +static const char** g_argn;
 +static const char** g_argv;
++static const char* g_tty_prefix;
 +static pthread_t g_sdl_thread;
 +
 +static void* sdl_thread_start(void*);

+#include <ppapi/c/pp_instance.h>
+#include <ppapi/c/ppb.h>
+#include <ppapi/c/ppb_input_event.h>
+#include <ppapi/c/ppb_view.h>
+#include <ppapi/c/ppp.h>
+#include <ppapi/c/ppp_input_event.h>

+  return NULL;
+}
+
+static ssize_t TtyOutputHandler(const char* buf, size_t count, void* user_data) {
+  // We prepend the prefix_ to the data in buf, then package it up
+  // and post it as a message to javascript.
+  char* message = (char*)malloc(count + strlen(g_tty_prefix));
+  strcpy(message, g_tty_prefix);
+  memcpy(message + strlen(g_tty_prefix), buf, count);
+  struct PP_Var var = g_var_interface->VarFromUtf8(message, count + strlen(g_tty_prefix));
+  g_messaging_interface->PostMessage(g_instance, var);
+  g_var_interface->Release(var);
+  free(message);
+  return count;
+}
+
+static void ProcessArgs() {
+  int i;
+  int rtn;
+  int mount_default = 1;
+  nacl_io_log("SDL: ProcessArgs %d\n", g_argc);
+
+  umount("/");
+
