summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/luv/tests/test-sigchld-after-lua_close.sh
diff options
context:
space:
mode:
author ImJezze <jezze@gmx.net>2016-02-21 11:48:45 +0100
committer ImJezze <jezze@gmx.net>2016-02-21 11:48:45 +0100
commitcc24a339d8c0517259084b5c178d784626ba965c (patch)
tree9868e9687b5802ae0a3733712a3bbeb3bc75c953 /3rdparty/luv/tests/test-sigchld-after-lua_close.sh
parentb5daabda5495dea5c50e17961ecfed2ea8619d76 (diff)
Merge remote-tracking branch 'refs/remotes/mamedev/master'
Second attempt
Diffstat (limited to '3rdparty/luv/tests/test-sigchld-after-lua_close.sh')
-rw-r--r--3rdparty/luv/tests/test-sigchld-after-lua_close.sh45
1 files changed, 45 insertions, 0 deletions
diff --git a/3rdparty/luv/tests/test-sigchld-after-lua_close.sh b/3rdparty/luv/tests/test-sigchld-after-lua_close.sh
new file mode 100644
index 00000000000..e7d22d3df36
--- /dev/null
+++ b/3rdparty/luv/tests/test-sigchld-after-lua_close.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+# Verifies that luv will cleanup libuv process handles correctly even if
+# not done by "userspace".
+# Details: https://github.com/luvit/luv/issues/193
+
+# This test modifies one of the examples to skip libuv process cleanup,
+# purposely making it leave SIGCHLD signal handler.
+#
+patch -p1 << "EOF"
+diff --git a/examples/talking-to-children.lua b/examples/talking-to-children.lua
+index 10a53ef..6c6c53f 100644
+--- a/examples/talking-to-children.lua
++++ b/examples/talking-to-children.lua
+@@ -41,7 +41,3 @@ uv.read_start(stdout, onread)
+ uv.read_start(stderr, onread)
+ uv.write(stdin, "Hello World")
+ uv.shutdown(stdin, onshutdown)
+-
+-uv.run()
+-uv.walk(uv.close)
+-uv.run()
+EOF
+
+# It also requires a patched lua standalone interpreter that sends SIGCHLD to
+# itself after calling lua_close, which would have freed all memory of the libuv
+# event loop associated with the lua state.
+(
+cd deps/lua
+patch -p1 << "EOF"
+diff --git a/src/lua.c b/src/lua.c
+index 7a47582..4dc19d5 100644
+--- a/src/lua.c
++++ b/src/lua.c
+@@ -608,6 +608,7 @@ int main (int argc, char **argv) {
+ result = lua_toboolean(L, -1); /* get result */
+ report(L, status);
+ lua_close(L);
++ kill(0, SIGCHLD);
+ return (result && status == LUA_OK) ? EXIT_SUCCESS : EXIT_FAILURE;
+ }
+EOF
+)
+
+WITH_LUA_ENGINE=Lua make
+./build/lua examples/talking-to-children.lua