mediawiki-extensions-Scribunto/engines/LuaStandalone
Brad Jorsch 7f94d88733 LuaStandalone: Fix signal handling
I252ec046 noticeably broke things by adding a dependency on the pcntl
functions, which tend not to be present under Apache.

It also subtly broke exit handling by using proc_close()'s return value,
which PHP mangles in such a way that we can't tell the difference
between an actual XCPU kill and exit( SIGXCPU ). This one wasn't noticed
because the pcntl functions interpret everything proc_close() is going
to return as a signal kill and we didn't test the 'exited' code path.

I'm not sure what was going on in I57cdf8aa since it provides no details
about what it was trying to fix, but that would have broken signal
handling in the other way: Ibf5f4656 worked because proc_open() on Linux
executes the command by passing it to /bin/sh -c, and that shell is
going to turn any signal that kills Lua (e.g. the SIGXCPU) into an exit
status of 128+signum.

To avoid proc_close()'s broken return value while also avoiding the
race, we can loop on proc_get_status() until $status['running'] is
false.

To have signals that kill Lua actually be interpreted as signals, we
have two options: add an "exec" in front of the command so proc_open()'s
/bin/sh -c is execed away, or detect shell-style signal reporting and
convert it. We may as well do both.

Bug: T128048
Change-Id: I8a62e1660fe1694e9ba5de77d01960c1ab4580aa
2017-03-09 23:16:28 +00:00
..
binaries Update lua binaries to patch CVE-2014-5461 2016-02-22 09:38:22 -08:00
lua_ulimit.sh Fix file permissions 2014-10-15 12:17:26 +00:00
LuaStandaloneEngine.php LuaStandalone: Fix signal handling 2017-03-09 23:16:28 +00:00
mw_main.lua Avoid running all of mw.lua twice 2014-05-15 14:15:08 -04:00
MWServer.lua LuaStandalone: Fix signal handling 2017-03-09 23:16:28 +00:00
protocol.txt LuaStandalone: Fix signal handling 2017-03-09 23:16:28 +00:00