about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/task.lua11
-rw-r--r--src/teliva.c2
2 files changed, 12 insertions, 1 deletions
diff --git a/src/task.lua b/src/task.lua
index 8d03316..3b00ef6 100644
--- a/src/task.lua
+++ b/src/task.lua
@@ -380,6 +380,17 @@ _M.RECV      = RECV
 _M.SEND      = SEND
 _M.NOP       = NOP
 
+-- Specific to Teliva
+function spawn_main()
+  task.spawn(main)
+  task.scheduler()
+  assert(false, "Teliva's scheduler ran out of work; this shouldn't happen.\n"..
+                "Either a channel is blocked forever or you're reading past\n"..
+                "the end of a file (after recv() returned nil).\n")
+  curses.nodelay(true)
+  curses.getch()
+end
+
 ----------------------------------------------------------------------------
 ----------------------------------------------------------------------------
 -- Tests
diff --git a/src/teliva.c b/src/teliva.c
index 90da6f1..2e9c9d9 100644
--- a/src/teliva.c
+++ b/src/teliva.c
@@ -1794,7 +1794,7 @@ int handle_image(lua_State* L, char** argv, int n) {
   /* initialize permissions */
   load_permissions_from_user_configuration(L);
   /* call main() */
-  lua_getglobal(L, "main");
+  lua_getglobal(L, "spawn_main");
   status = docall(L, 0, 1);
   if (status != 0) return report_in_developer_mode(L, status);
   return 0;