aboutsummaryrefslogtreecommitdiff
path: root/src/luajit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/luajit.c')
-rw-r--r--src/luajit.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/luajit.c b/src/luajit.c
index b4044d22..b7d9d0c1 100644
--- a/src/luajit.c
+++ b/src/luajit.c
@@ -6,7 +6,6 @@
6** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h 6** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
7*/ 7*/
8 8
9#include <signal.h>
10#include <stdio.h> 9#include <stdio.h>
11#include <stdlib.h> 10#include <stdlib.h>
12#include <string.h> 11#include <string.h>
@@ -34,9 +33,14 @@
34#define lua_stdin_is_tty() 1 33#define lua_stdin_is_tty() 1
35#endif 34#endif
36 35
36#if !LJ_TARGET_CONSOLE
37#include <signal.h>
38#endif
39
37static lua_State *globalL = NULL; 40static lua_State *globalL = NULL;
38static const char *progname = LUA_PROGNAME; 41static const char *progname = LUA_PROGNAME;
39 42
43#if !LJ_TARGET_CONSOLE
40static void lstop(lua_State *L, lua_Debug *ar) 44static void lstop(lua_State *L, lua_Debug *ar)
41{ 45{
42 (void)ar; /* unused arg. */ 46 (void)ar; /* unused arg. */
@@ -53,6 +57,7 @@ static void laction(int i)
53 terminate process (default action) */ 57 terminate process (default action) */
54 lua_sethook(globalL, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1); 58 lua_sethook(globalL, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1);
55} 59}
60#endif
56 61
57static void print_usage(void) 62static void print_usage(void)
58{ 63{
@@ -122,9 +127,13 @@ static int docall(lua_State *L, int narg, int clear)
122 int base = lua_gettop(L) - narg; /* function index */ 127 int base = lua_gettop(L) - narg; /* function index */
123 lua_pushcfunction(L, traceback); /* push traceback function */ 128 lua_pushcfunction(L, traceback); /* push traceback function */
124 lua_insert(L, base); /* put it under chunk and args */ 129 lua_insert(L, base); /* put it under chunk and args */
130#if !LJ_TARGET_CONSOLE
125 signal(SIGINT, laction); 131 signal(SIGINT, laction);
132#endif
126 status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base); 133 status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base);
134#if !LJ_TARGET_CONSOLE
127 signal(SIGINT, SIG_DFL); 135 signal(SIGINT, SIG_DFL);
136#endif
128 lua_remove(L, base); /* remove traceback function */ 137 lua_remove(L, base); /* remove traceback function */
129 /* force a complete garbage collection in case of errors */ 138 /* force a complete garbage collection in case of errors */
130 if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0); 139 if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0);
@@ -484,7 +493,11 @@ static int runargs(lua_State *L, char **argv, int n)
484 493
485static int handle_luainit(lua_State *L) 494static int handle_luainit(lua_State *L)
486{ 495{
496#if LJ_TARGET_CONSOLE
497 const char *init = NULL;
498#else
487 const char *init = getenv(LUA_INIT); 499 const char *init = getenv(LUA_INIT);
500#endif
488 if (init == NULL) 501 if (init == NULL)
489 return 0; /* status OK */ 502 return 0; /* status OK */
490 else if (init[0] == '@') 503 else if (init[0] == '@')