Annotate

util-src/signal.c @ 10805:d17392022cb2

mod_muc: let event handlers modify cloned presence Updates #1533
author JC Brand <jc@opkode.com>
date Wed, 22 Apr 2020 16:12:15 +0200
parent 10799:763bb2ce3f60
child 12575:1f6f05a98fcd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 /*
2405
88f73ee1c46f util.signal: Update header comment for new filename
Matthew Wild <mwild1@gmail.com>
parents: 2343
diff changeset
2 * signal.c -- Signal Handler Library for Lua
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3 *
2431
c4d32b35fe60 util.signal: Update version in header, and author's email
Matthew Wild <mwild1@gmail.com>
parents: 2430
diff changeset
4 * Version: 1.000+changes
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5 *
2431
c4d32b35fe60 util.signal: Update version in header, and author's email
Matthew Wild <mwild1@gmail.com>
parents: 2430
diff changeset
6 * Copyright (C) 2007 Patrick J. Donnelly (batrick@batbytes.com)
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 *
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 * This software is distributed under the same license as Lua 5.0:
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 *
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 * Permission is hereby granted, free of charge, to any person obtaining a
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 * copy of this software and associated documentation files (the "Software"),
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 * to deal in the Software without restriction, including without limitation
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 * and/or sell copies of the Software, and to permit persons to whom the
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 * Software is furnished to do so, subject to the following conditions:
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 *
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 * The above copyright notice and this permission notice shall be included
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 * in all copies or substantial portions of the Software.
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 *
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
24 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
26 * OTHER DEALINGS IN THE SOFTWARE.
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 */
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
28
9150
c1d5f52274cf net, pposix, signal: Check for redefined defines, fix warnings.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 8420
diff changeset
29 #ifndef _GNU_SOURCE
7973
703f7f45feb4 util.signal: Enable all GNU features, _DEFAULT_SOURCE doesn't have the desired effect before glibc 2.19
Kim Alvefur <zash@zash.se>
parents: 7971
diff changeset
30 #define _GNU_SOURCE
9150
c1d5f52274cf net, pposix, signal: Check for redefined defines, fix warnings.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 8420
diff changeset
31 #endif
7931
b619b85e01aa util.pposix, configure: Move _GNU_SOURCE macro into source files
Kim Alvefur <zash@zash.se>
parents: 7889
diff changeset
32
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
33 #include <signal.h>
2459
66f60e69567b util.signal: Using stdlib.h instead of malloc.h.
Tobias Markmann <tm@ayena.de>
parents: 2432
diff changeset
34 #include <stdlib.h>
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
35
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
36 #include "lua.h"
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
37 #include "lauxlib.h"
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
38
6789
6b180e77c97a util-src/*.c: Invert Lua 5.2 compat to be 5.2+ by default and a macro to support 5.1
Kim Alvefur <zash@zash.se>
parents: 6620
diff changeset
39 #if (LUA_VERSION_NUM == 501)
6b180e77c97a util-src/*.c: Invert Lua 5.2 compat to be 5.2+ by default and a macro to support 5.1
Kim Alvefur <zash@zash.se>
parents: 6620
diff changeset
40 #define luaL_setfuncs(L, R, N) luaL_register(L, NULL, R)
6413
a552f4170aed util-src/*.c: Add macro for compiling with Lua 5.2
Kim Alvefur <zash@zash.se>
parents: 6412
diff changeset
41 #endif
10799
763bb2ce3f60 util.pposix,signal: Pass around various OS numbers as integers [Lua 5.3]
Kim Alvefur <zash@zash.se>
parents: 10480
diff changeset
42 #if (LUA_VERSION_NUM < 503)
763bb2ce3f60 util.pposix,signal: Pass around various OS numbers as integers [Lua 5.3]
Kim Alvefur <zash@zash.se>
parents: 10480
diff changeset
43 #define lua_isinteger(L, n) lua_isnumber(L, n)
763bb2ce3f60 util.pposix,signal: Pass around various OS numbers as integers [Lua 5.3]
Kim Alvefur <zash@zash.se>
parents: 10480
diff changeset
44 #endif
6413
a552f4170aed util-src/*.c: Add macro for compiling with Lua 5.2
Kim Alvefur <zash@zash.se>
parents: 6412
diff changeset
45
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
46 #ifndef lsig
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
47
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
48 #define lsig
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
49
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
50 struct lua_signal {
7889
b8d694646597 util-src/*.c: Attach pointer * to name instead of type
Kim Alvefur <zash@zash.se>
parents: 7818
diff changeset
51 char *name; /* name of the signal */
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
52 int sig; /* the signal */
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
53 };
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
54
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
55 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
56
8414
7ea3311ca632 util.signal: Use a static array to keep track of pending signals (fixes #1029)
Kim Alvefur <zash@zash.se>
parents: 7973
diff changeset
57 #define MAX_PENDING_SIGNALS 32
7ea3311ca632 util.signal: Use a static array to keep track of pending signals (fixes #1029)
Kim Alvefur <zash@zash.se>
parents: 7973
diff changeset
58
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
59 #define LUA_SIGNAL "lua_signal"
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
60
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
61 static const struct lua_signal lua_signals[] = {
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
62 /* ANSI C signals */
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
63 #ifdef SIGABRT
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
64 {"SIGABRT", SIGABRT},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
65 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
66 #ifdef SIGFPE
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
67 {"SIGFPE", SIGFPE},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
68 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
69 #ifdef SIGILL
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
70 {"SIGILL", SIGILL},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
71 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
72 #ifdef SIGINT
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
73 {"SIGINT", SIGINT},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
74 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
75 #ifdef SIGSEGV
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
76 {"SIGSEGV", SIGSEGV},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
77 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
78 #ifdef SIGTERM
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
79 {"SIGTERM", SIGTERM},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
80 #endif
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
81 /* posix signals */
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
82 #ifdef SIGHUP
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
83 {"SIGHUP", SIGHUP},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
84 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
85 #ifdef SIGQUIT
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
86 {"SIGQUIT", SIGQUIT},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
87 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
88 #ifdef SIGTRAP
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
89 {"SIGTRAP", SIGTRAP},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
90 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
91 #ifdef SIGKILL
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
92 {"SIGKILL", SIGKILL},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
93 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
94 #ifdef SIGUSR1
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
95 {"SIGUSR1", SIGUSR1},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
96 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
97 #ifdef SIGUSR2
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
98 {"SIGUSR2", SIGUSR2},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
99 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
100 #ifdef SIGPIPE
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
101 {"SIGPIPE", SIGPIPE},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
102 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
103 #ifdef SIGALRM
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
104 {"SIGALRM", SIGALRM},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
105 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
106 #ifdef SIGCHLD
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
107 {"SIGCHLD", SIGCHLD},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
108 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
109 #ifdef SIGCONT
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
110 {"SIGCONT", SIGCONT},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
111 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
112 #ifdef SIGSTOP
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
113 {"SIGSTOP", SIGSTOP},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
114 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
115 #ifdef SIGTTIN
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
116 {"SIGTTIN", SIGTTIN},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
117 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
118 #ifdef SIGTTOU
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
119 {"SIGTTOU", SIGTTOU},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
120 #endif
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
121 /* some BSD signals */
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
122 #ifdef SIGIOT
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
123 {"SIGIOT", SIGIOT},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
124 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
125 #ifdef SIGBUS
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
126 {"SIGBUS", SIGBUS},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
127 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
128 #ifdef SIGCLD
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
129 {"SIGCLD", SIGCLD},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
130 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
131 #ifdef SIGURG
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
132 {"SIGURG", SIGURG},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
133 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
134 #ifdef SIGXCPU
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
135 {"SIGXCPU", SIGXCPU},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
136 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
137 #ifdef SIGXFSZ
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
138 {"SIGXFSZ", SIGXFSZ},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
139 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
140 #ifdef SIGVTALRM
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
141 {"SIGVTALRM", SIGVTALRM},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
142 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
143 #ifdef SIGPROF
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
144 {"SIGPROF", SIGPROF},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
145 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
146 #ifdef SIGWINCH
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
147 {"SIGWINCH", SIGWINCH},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
148 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
149 #ifdef SIGPOLL
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
150 {"SIGPOLL", SIGPOLL},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
151 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
152 #ifdef SIGIO
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
153 {"SIGIO", SIGIO},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
154 #endif
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
155 /* add odd signals */
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
156 #ifdef SIGSTKFLT
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
157 {"SIGSTKFLT", SIGSTKFLT}, /* stack fault */
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
158 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
159 #ifdef SIGSYS
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
160 {"SIGSYS", SIGSYS},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
161 #endif
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
162 {NULL, 0}
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
163 };
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
164
7889
b8d694646597 util-src/*.c: Attach pointer * to name instead of type
Kim Alvefur <zash@zash.se>
parents: 7818
diff changeset
165 static lua_State *Lsig = NULL;
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
166 static lua_Hook Hsig = NULL;
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
167 static int Hmask = 0;
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
168 static int Hcount = 0;
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
169
10480
94cacf9fd0ae util.*.c: Add static qualifiers everywhere
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 9151
diff changeset
170 static int signals[MAX_PENDING_SIGNALS];
94cacf9fd0ae util.*.c: Add static qualifiers everywhere
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 9151
diff changeset
171 static int nsig = 0;
2430
69d377c84fe3 util.signal: Queue up multiple signals, instead of trampling on the previous debug hook (and never clearing our own)
Matthew Wild <mwild1@gmail.com>
parents: 2405
diff changeset
172
7889
b8d694646597 util-src/*.c: Attach pointer * to name instead of type
Kim Alvefur <zash@zash.se>
parents: 7818
diff changeset
173 static void sighook(lua_State *L, lua_Debug *ar) {
9151
fee3933ff346 pposix, signal: Ignore unused arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 9150
diff changeset
174 (void)ar;
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
175 /* restore the old hook */
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
176 lua_sethook(L, Hsig, Hmask, Hcount);
2432
1e045b3e9dce util.signal: Restore the old debug hook earlier, just in case we receive another signal between clearing the signal queue and restoring it
Matthew Wild <mwild1@gmail.com>
parents: 2431
diff changeset
177
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
178 lua_pushstring(L, LUA_SIGNAL);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
179 lua_gettable(L, LUA_REGISTRYINDEX);
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
180
8420
fb27aff6d491 util.signal: Fix loop (fixes #1047)
Kim Alvefur <zash@zash.se>
parents: 8414
diff changeset
181 for(int i = 0; i < nsig; i++) {
10799
763bb2ce3f60 util.pposix,signal: Pass around various OS numbers as integers [Lua 5.3]
Kim Alvefur <zash@zash.se>
parents: 10480
diff changeset
182 lua_pushinteger(L, signals[i]);
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
183 lua_gettable(L, -2);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
184 lua_call(L, 0, 0);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
185 };
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
186
8414
7ea3311ca632 util.signal: Use a static array to keep track of pending signals (fixes #1029)
Kim Alvefur <zash@zash.se>
parents: 7973
diff changeset
187 nsig = 0;
7ea3311ca632 util.signal: Use a static array to keep track of pending signals (fixes #1029)
Kim Alvefur <zash@zash.se>
parents: 7973
diff changeset
188
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
189 lua_pop(L, 1); /* pop lua_signal table */
2430
69d377c84fe3 util.signal: Queue up multiple signals, instead of trampling on the previous debug hook (and never clearing our own)
Matthew Wild <mwild1@gmail.com>
parents: 2405
diff changeset
190
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
191 }
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
192
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
193 static void handle(int sig) {
8414
7ea3311ca632 util.signal: Use a static array to keep track of pending signals (fixes #1029)
Kim Alvefur <zash@zash.se>
parents: 7973
diff changeset
194 if(nsig == 0) {
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
195 /* Store the existing debug hook (if any) and its parameters */
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
196 Hsig = lua_gethook(Lsig);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
197 Hmask = lua_gethookmask(Lsig);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
198 Hcount = lua_gethookcount(Lsig);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
199
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
200 /* Set our new debug hook */
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
201 lua_sethook(Lsig, sighook, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1);
8414
7ea3311ca632 util.signal: Use a static array to keep track of pending signals (fixes #1029)
Kim Alvefur <zash@zash.se>
parents: 7973
diff changeset
202 }
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
203
8414
7ea3311ca632 util.signal: Use a static array to keep track of pending signals (fixes #1029)
Kim Alvefur <zash@zash.se>
parents: 7973
diff changeset
204 if(nsig < MAX_PENDING_SIGNALS) {
8420
fb27aff6d491 util.signal: Fix loop (fixes #1047)
Kim Alvefur <zash@zash.se>
parents: 8414
diff changeset
205 signals[nsig++] = sig;
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
206 }
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
207 }
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
208
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
209 /*
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
210 * l_signal == signal(signal [, func [, chook]])
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
211 *
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
212 * signal = signal number or string
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
213 * func = Lua function to call
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
214 * chook = catch within C functions
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
215 * if caught, Lua function _must_
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
216 * exit, as the stack is most likely
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
217 * in an unstable state.
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
218 */
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
219
7889
b8d694646597 util-src/*.c: Attach pointer * to name instead of type
Kim Alvefur <zash@zash.se>
parents: 7818
diff changeset
220 static int l_signal(lua_State *L) {
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
221 int args = lua_gettop(L);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
222 int t, sig; /* type, signal */
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
223
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
224 /* get type of signal */
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
225 luaL_checkany(L, 1);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
226 t = lua_type(L, 1);
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
227
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
228 if(t == LUA_TNUMBER) {
10799
763bb2ce3f60 util.pposix,signal: Pass around various OS numbers as integers [Lua 5.3]
Kim Alvefur <zash@zash.se>
parents: 10480
diff changeset
229 sig = (int) lua_tointeger(L, 1);
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
230 } else if(t == LUA_TSTRING) {
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
231 lua_pushstring(L, LUA_SIGNAL);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
232 lua_gettable(L, LUA_REGISTRYINDEX);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
233 lua_pushvalue(L, 1);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
234 lua_gettable(L, -2);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
235
10799
763bb2ce3f60 util.pposix,signal: Pass around various OS numbers as integers [Lua 5.3]
Kim Alvefur <zash@zash.se>
parents: 10480
diff changeset
236 if(!lua_isinteger(L, -1)) {
6620
50eaefeec013 util-src/*.c: Per convention call luaL_error() as argument to return
Florian Zeitz <florob@babelmonkeys.de>
parents: 6615
diff changeset
237 return luaL_error(L, "invalid signal string");
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
238 }
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
239
10799
763bb2ce3f60 util.pposix,signal: Pass around various OS numbers as integers [Lua 5.3]
Kim Alvefur <zash@zash.se>
parents: 10480
diff changeset
240 sig = (int) lua_tointeger(L, -1);
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
241 lua_pop(L, 1); /* get rid of number we pushed */
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
242 } else {
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
243 luaL_checknumber(L, 1); /* will always error, with good error msg */
6620
50eaefeec013 util-src/*.c: Per convention call luaL_error() as argument to return
Florian Zeitz <florob@babelmonkeys.de>
parents: 6615
diff changeset
244 return luaL_error(L, "unreachable: invalid number was accepted");
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
245 }
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
246
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
247 /* set handler */
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
248 if(args == 1 || lua_isnil(L, 2)) { /* clear handler */
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
249 lua_pushstring(L, LUA_SIGNAL);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
250 lua_gettable(L, LUA_REGISTRYINDEX);
10799
763bb2ce3f60 util.pposix,signal: Pass around various OS numbers as integers [Lua 5.3]
Kim Alvefur <zash@zash.se>
parents: 10480
diff changeset
251 lua_pushinteger(L, sig);
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
252 lua_gettable(L, -2); /* return old handler */
10799
763bb2ce3f60 util.pposix,signal: Pass around various OS numbers as integers [Lua 5.3]
Kim Alvefur <zash@zash.se>
parents: 10480
diff changeset
253 lua_pushinteger(L, sig);
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
254 lua_pushnil(L);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
255 lua_settable(L, -4);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
256 lua_remove(L, -2); /* remove LUA_SIGNAL table */
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
257 signal(sig, SIG_DFL);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
258 } else {
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
259 luaL_checktype(L, 2, LUA_TFUNCTION);
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
260
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
261 lua_pushstring(L, LUA_SIGNAL);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
262 lua_gettable(L, LUA_REGISTRYINDEX);
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
263
10799
763bb2ce3f60 util.pposix,signal: Pass around various OS numbers as integers [Lua 5.3]
Kim Alvefur <zash@zash.se>
parents: 10480
diff changeset
264 lua_pushinteger(L, sig);
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
265 lua_pushvalue(L, 2);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
266 lua_settable(L, -3);
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
267
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
268 /* Set the state for the handler */
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
269 Lsig = L;
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
270
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
271 if(lua_toboolean(L, 3)) { /* c hook? */
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
272 if(signal(sig, handle) == SIG_ERR) {
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
273 lua_pushboolean(L, 0);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
274 } else {
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
275 lua_pushboolean(L, 1);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
276 }
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
277 } else { /* lua_hook */
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
278 if(signal(sig, handle) == SIG_ERR) {
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
279 lua_pushboolean(L, 0);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
280 } else {
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
281 lua_pushboolean(L, 1);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
282 }
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
283 }
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
284 }
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
285
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
286 return 1;
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
287 }
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
288
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
289 /*
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
290 * l_raise == raise(signal)
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
291 *
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
292 * signal = signal number or string
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
293 */
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
294
7889
b8d694646597 util-src/*.c: Attach pointer * to name instead of type
Kim Alvefur <zash@zash.se>
parents: 7818
diff changeset
295 static int l_raise(lua_State *L) {
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
296 /* int args = lua_gettop(L); */
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
297 int t = 0; /* type */
10799
763bb2ce3f60 util.pposix,signal: Pass around various OS numbers as integers [Lua 5.3]
Kim Alvefur <zash@zash.se>
parents: 10480
diff changeset
298 lua_Integer ret;
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
299
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
300 luaL_checkany(L, 1);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
301
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
302 t = lua_type(L, 1);
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
303
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
304 if(t == LUA_TNUMBER) {
10799
763bb2ce3f60 util.pposix,signal: Pass around various OS numbers as integers [Lua 5.3]
Kim Alvefur <zash@zash.se>
parents: 10480
diff changeset
305 ret = (lua_Integer) raise((int) lua_tointeger(L, 1));
763bb2ce3f60 util.pposix,signal: Pass around various OS numbers as integers [Lua 5.3]
Kim Alvefur <zash@zash.se>
parents: 10480
diff changeset
306 lua_pushinteger(L, ret);
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
307 } else if(t == LUA_TSTRING) {
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
308 lua_pushstring(L, LUA_SIGNAL);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
309 lua_gettable(L, LUA_REGISTRYINDEX);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
310 lua_pushvalue(L, 1);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
311 lua_gettable(L, -2);
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
312
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
313 if(!lua_isnumber(L, -1)) {
6620
50eaefeec013 util-src/*.c: Per convention call luaL_error() as argument to return
Florian Zeitz <florob@babelmonkeys.de>
parents: 6615
diff changeset
314 return luaL_error(L, "invalid signal string");
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
315 }
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
316
10799
763bb2ce3f60 util.pposix,signal: Pass around various OS numbers as integers [Lua 5.3]
Kim Alvefur <zash@zash.se>
parents: 10480
diff changeset
317 ret = (lua_Integer) raise((int) lua_tointeger(L, -1));
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
318 lua_pop(L, 1); /* get rid of number we pushed */
10799
763bb2ce3f60 util.pposix,signal: Pass around various OS numbers as integers [Lua 5.3]
Kim Alvefur <zash@zash.se>
parents: 10480
diff changeset
319 lua_pushinteger(L, ret);
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
320 } else {
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
321 luaL_checknumber(L, 1); /* will always error, with good error msg */
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
322 }
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
323
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
324 return 1;
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
325 }
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
326
3282
8ef3beed0779 util.signal: Make kill() available on OS X (thanks darkrain).
Waqas Hussain <waqas20@gmail.com>
parents: 3274
diff changeset
327 #if defined(__unix__) || defined(__APPLE__)
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
328
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
329 /* define some posix only functions */
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
330
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
331 /*
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
332 * l_kill == kill(pid, signal)
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
333 *
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
334 * pid = process id
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
335 * signal = signal number or string
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
336 */
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
337
7889
b8d694646597 util-src/*.c: Attach pointer * to name instead of type
Kim Alvefur <zash@zash.se>
parents: 7818
diff changeset
338 static int l_kill(lua_State *L) {
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
339 int t; /* type */
10799
763bb2ce3f60 util.pposix,signal: Pass around various OS numbers as integers [Lua 5.3]
Kim Alvefur <zash@zash.se>
parents: 10480
diff changeset
340 lua_Integer ret; /* return value */
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
341
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
342 luaL_checknumber(L, 1); /* must be int for pid */
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
343 luaL_checkany(L, 2); /* check for a second arg */
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
344
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
345 t = lua_type(L, 2);
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
346
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
347 if(t == LUA_TNUMBER) {
10799
763bb2ce3f60 util.pposix,signal: Pass around various OS numbers as integers [Lua 5.3]
Kim Alvefur <zash@zash.se>
parents: 10480
diff changeset
348 ret = (lua_Integer) kill((int) lua_tointeger(L, 1),
763bb2ce3f60 util.pposix,signal: Pass around various OS numbers as integers [Lua 5.3]
Kim Alvefur <zash@zash.se>
parents: 10480
diff changeset
349 (int) lua_tointeger(L, 2));
763bb2ce3f60 util.pposix,signal: Pass around various OS numbers as integers [Lua 5.3]
Kim Alvefur <zash@zash.se>
parents: 10480
diff changeset
350 lua_pushinteger(L, ret);
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
351 } else if(t == LUA_TSTRING) {
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
352 lua_pushstring(L, LUA_SIGNAL);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
353 lua_gettable(L, LUA_REGISTRYINDEX);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
354 lua_pushvalue(L, 2);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
355 lua_gettable(L, -2);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
356
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
357 if(!lua_isnumber(L, -1)) {
6620
50eaefeec013 util-src/*.c: Per convention call luaL_error() as argument to return
Florian Zeitz <florob@babelmonkeys.de>
parents: 6615
diff changeset
358 return luaL_error(L, "invalid signal string");
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
359 }
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
360
10799
763bb2ce3f60 util.pposix,signal: Pass around various OS numbers as integers [Lua 5.3]
Kim Alvefur <zash@zash.se>
parents: 10480
diff changeset
361 ret = (lua_Integer) kill((int) lua_tointeger(L, 1),
763bb2ce3f60 util.pposix,signal: Pass around various OS numbers as integers [Lua 5.3]
Kim Alvefur <zash@zash.se>
parents: 10480
diff changeset
362 (int) lua_tointeger(L, -1));
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
363 lua_pop(L, 1); /* get rid of number we pushed */
10799
763bb2ce3f60 util.pposix,signal: Pass around various OS numbers as integers [Lua 5.3]
Kim Alvefur <zash@zash.se>
parents: 10480
diff changeset
364 lua_pushinteger(L, ret);
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
365 } else {
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
366 luaL_checknumber(L, 2); /* will always error, with good error msg */
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
367 }
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
368
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
369 return 1;
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
370 }
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
371
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
372 #endif
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
373
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
374 static const struct luaL_Reg lsignal_lib[] = {
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
375 {"signal", l_signal},
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
376 {"raise", l_raise},
3282
8ef3beed0779 util.signal: Make kill() available on OS X (thanks darkrain).
Waqas Hussain <waqas20@gmail.com>
parents: 3274
diff changeset
377 #if defined(__unix__) || defined(__APPLE__)
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
378 {"kill", l_kill},
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
379 #endif
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
380 {NULL, NULL}
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
381 };
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
382
7889
b8d694646597 util-src/*.c: Attach pointer * to name instead of type
Kim Alvefur <zash@zash.se>
parents: 7818
diff changeset
383 int luaopen_util_signal(lua_State *L) {
7818
54669df178c2 util-src: Make C modules assert that the Lua runtime matches what it was compiled for
Kim Alvefur <zash@zash.se>
parents: 6789
diff changeset
384 #if (LUA_VERSION_NUM > 501)
54669df178c2 util-src: Make C modules assert that the Lua runtime matches what it was compiled for
Kim Alvefur <zash@zash.se>
parents: 6789
diff changeset
385 luaL_checkversion(L);
54669df178c2 util-src: Make C modules assert that the Lua runtime matches what it was compiled for
Kim Alvefur <zash@zash.se>
parents: 6789
diff changeset
386 #endif
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
387 int i = 0;
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
388
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
389 /* add the library */
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
390 lua_newtable(L);
6789
6b180e77c97a util-src/*.c: Invert Lua 5.2 compat to be 5.2+ by default and a macro to support 5.1
Kim Alvefur <zash@zash.se>
parents: 6620
diff changeset
391 luaL_setfuncs(L, lsignal_lib, 0);
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
392
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
393 /* push lua_signals table into the registry */
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
394 /* put the signals inside the library table too,
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
395 * they are only a reference */
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
396 lua_pushstring(L, LUA_SIGNAL);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
397 lua_newtable(L);
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
398
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
399 while(lua_signals[i].name != NULL) {
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
400 /* registry table */
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
401 lua_pushstring(L, lua_signals[i].name);
10799
763bb2ce3f60 util.pposix,signal: Pass around various OS numbers as integers [Lua 5.3]
Kim Alvefur <zash@zash.se>
parents: 10480
diff changeset
402 lua_pushinteger(L, lua_signals[i].sig);
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
403 lua_settable(L, -3);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
404 /* signal table */
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
405 lua_pushstring(L, lua_signals[i].name);
10799
763bb2ce3f60 util.pposix,signal: Pass around various OS numbers as integers [Lua 5.3]
Kim Alvefur <zash@zash.se>
parents: 10480
diff changeset
406 lua_pushinteger(L, lua_signals[i].sig);
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
407 lua_settable(L, -5);
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
408 i++;
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
409 }
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
410
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
411 /* add newtable to the registry */
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
412 lua_settable(L, LUA_REGISTRYINDEX);
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
413
6615
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6413
diff changeset
414 return 1;
988
8cb9a0d59e78 util.lsignal: Add lsignal library for catching POSIX signals
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
415 }