From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id C96CF6EC44; Tue, 3 Nov 2026 15:15:14 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C96CF6EC44 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1793708114; bh=Hwyn2p+AD4L5766BsO7yi/iqC6fUBtjPkVK9nzL/IdY=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=JdXQOzrwtuFiLnhgEqTuPjR5zr9u5LdKc7E/1l+7QtQaKmy7urEYUVssYoJP5VKzJ 0NlK6QhPXIr6X4dN7cIT1uu90GJoWtbAaoYrriwx5eG4Fnq/T1n6ADmm32B1XuLbzH 19Y/SQVfUXTN/5swsIl4YXfACxBvdEXXcGQSghSI= Received: from send59.i.mail.ru (send59.i.mail.ru [89.221.237.154]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id CB1176EC44 for ; Tue, 3 Nov 2026 15:15:12 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org CB1176EC44 Received: by exim-smtp-675c6798c6-6nrc5 with esmtpa (envelope-from ) id 1xODPz-0000000074r-3vg9; Tue, 03 Nov 2026 15:15:12 +0300 Date: Tue, 3 Nov 2026 15:14:46 +0300 To: Evgeniy Temirgaleev Message-ID: References: <68d8da9f72cbf7237b0e21f9c643789d36fa82a8.1793574664.git.e.temirgaleev@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <68d8da9f72cbf7237b0e21f9c643789d36fa82a8.1793574664.git.e.temirgaleev@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9A795A6FBED20F5A22B25B4142FBED1B4E03D23B8ACDC023D182A05F538085040867260034D0ACD6D3DE06ABAFEAF6705724350C9FD27D819C30D331041F2DAA8DFC3AC920C90DFFD X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE78CB87876C5D626D4EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB55337566509B1718B586E08551C925238252FEB06C935BDE81BCA535117D896BCEE597DC389733CBF5DBD5E9D5E8D9A59859A8B652D31B9D28593E51CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB86D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE7D699F3A2029486C7731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A54A38FA0F5FC44CFF5002B1117B3ED6969DA532B656EE2113559C6C5561145D6F823CB91A9FED034534781492E4B8EEAD9CFA8CFAC159CE19BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE191716CD42B3DD1D34CAB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D65908D87C0292ACEE578C30DA104D3CADFA36325E1508A2919BEB8B4EEAC42CD192A9D5A08F54F0FDE0B8341EE9D5BE9A0A3BA6ECCE0C615C4F32F37EF7D06AA1E7047501231A3896536536EB022892E5344C41F94D744909CECFA6C6B0C050A61A8CAF69B82BA93681CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXOcIETfglQORZ0zpDET4Zrk3igikrdHlWKb3X25CFjh0DLEd9SnCO68= X-Mailru-Sender: 689FA8AB762F73937C9FA53A4753B31332B819D8E48C0C3C6D01A4E25B454AB988804AE80DB691A1E49D44BB4BD9522A059A1ED8796F048DB274557F927329BE89D5A3BC2B10C37545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit v3 2/2] Improve CLI signal handling on POSIX. X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Kaplun via Tarantool-patches Reply-To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Envgeniy, Thanks for the patch! LGTM, with minor nits below. On 02.11.26, Evgeniy Temirgaleev wrote: > From: Mike Pall > > (cherry picked from commit 423ac2144b0447c925596f4d93e073ce501ed4e1) > > An obsolete signal() function in glibc is implemented as a wrapper for > POSIX sigaction() call with BSD semantic. In particular, it provides Typo: s/semantic/semantics/ > an SA_RESTART flag for SIGINT handler [1-2]. The latter makes certain > system calls, e.g. read() or wait(), restartable across signals [3]. > > The patch switches from signal() to sigaction() for POSIX systems > to obtain an explicit control of the signal flag set, which must > not contain SA_RESTART flag. (Actually, the empty flag set is > used.) > > 1. https://man7.org/linux/man-pages/man2/signal.2.html > 2. https://ftp.gnu.org/gnu/glibc/glibc-2.44.tar.xz (sysdeps/posix/signal.c, line 44) > 3. https://man7.org/linux/man-pages/man2/sigaction.2.html > > Temir Galeev: > * added the description and the test for the problem > > Part of tarantool/tarantool#13442 > --- > src/luajit.c | 23 +++++-- > ...ket-fix-cli-posix-sigint-handling.test.lua | 64 +++++++++++++++++++ > .../script.lua | 26 ++++++++ > 3 files changed, 109 insertions(+), 4 deletions(-) > create mode 100644 test/tarantool-tests/lj-noticket-fix-cli-posix-sigint-handling.test.lua > create mode 100644 test/tarantool-tests/lj-noticket-fix-cli-posix-sigint-handling/script.lua > > diff --git a/src/luajit.c b/src/luajit.c > index d9d85361..d35bea54 100644 > --- a/src/luajit.c > +++ b/src/luajit.c > diff --git a/test/tarantool-tests/lj-noticket-fix-cli-posix-sigint-handling.test.lua b/test/tarantool-tests/lj-noticket-fix-cli-posix-sigint-handling.test.lua > new file mode 100644 > index 00000000..5b235660 > --- /dev/null > +++ b/test/tarantool-tests/lj-noticket-fix-cli-posix-sigint-handling.test.lua > @@ -0,0 +1,64 @@ > +local tap = require('tap') > + > +-- The test checks that luajit CLI stop hook is executed on Typo: s/luajit/the LuaJIT/ > +-- SIGINT on a blocking system call (read(), waitpid(), etc.). > +-- > +-- The test runs luajit CLI with a script, which prints it's PID Typo: s/luajit/the LuaJIT/ Typo: s/it's/its/ > +-- as a ready marker and blocks on a read() call. After the > +-- child's PID number is read from child's pipe, the test send Typo: s/child's/the child's/ Typo: s/send/sends/ > +-- SIGINT to the child. > +-- With a patch applied (no SA_RESTART flag for SIGINT handler) > +-- read() call is interrupted and the CLI's Lua stop hook > +-- executed. Typo: s/executed/is executed/ > +-- Without a patch (SA_RESTART flag is present for SIGINT > +-- handler) read() call is restarted, the test and the child is Typo: s/is blocked/are blocked/ > +-- blocked on a pipe read until the child is terminated by > +-- SIGALRM. The test reads nothing from the child and fails. > + > +local test = tap.test('lj-noticket-fix-cli-posix-sigint-handling'):skipcond({ > + -- The patched code is not present in Tarantool binary: > + ["Disabled due to Tarantool uses it's own signal handling"] = _TARANTOOL, Nit: s/"/'/g > + ['Disabled on POSIX nonconformant OS'] = jit.os ~= 'BSD' and > + jit.os ~= 'Linux' and > + jit.os ~= 'OSX' and > + jit.os ~= 'POSIX', > +}) > + > +local ffi = require('ffi') > +ffi.cdef[[ > + int kill(int pid, int sig); > +]] > +local SIGINT = 2 > + > +test:plan(1) > +local utils = require('utils') > +local script = utils.exec.test_data(arg, 'script.lua') > +local cmd = ('exec %s %s 2>&1'):format(utils.exec.luacmd(arg), script) > +local proc = io.popen(cmd) > + > +local MARKER = 'CHILD_PID:' > +local RMARKER = '^'..MARKER..'(%d+)$' Typo: s/../ .. /g > +-- The child prints its PID after the CLI has installed the SIGINT > +-- handler, so it is a readiness marker. Skip possible noise > +-- lines, collect pre-marker output for error reporting. > +local lines_for_diag = {'child output:'} > +local pid, line > +repeat > + line = proc:read('*l') > + if line ~= nil then > + table.insert(lines_for_diag, line) > + local match = line:match(RMARKER) > + if match ~= nil then pid = tonumber(match) end > + end > +until line == nil or pid ~= nil > +if pid == nil then > + test:diag(table.concat(lines_for_diag, '\n')) > +end > +assert(pid ~= nil, 'the child process must report its PID') > + > +local res = ffi.C.kill(pid, SIGINT) > +assert(res == 0, 'SIGINT delivery failed') > +local output = proc:read('*a') > +proc:close() > +test:like(output, 'interrupted!', 'SIGINT interrupts the blocking call') > +test:done(true) > diff --git a/test/tarantool-tests/lj-noticket-fix-cli-posix-sigint-handling/script.lua b/test/tarantool-tests/lj-noticket-fix-cli-posix-sigint-handling/script.lua > new file mode 100644 > index 00000000..d2430a52 > --- /dev/null > +++ b/test/tarantool-tests/lj-noticket-fix-cli-posix-sigint-handling/script.lua > @@ -0,0 +1,26 @@ > +local ffi = require('ffi') > + > +ffi.cdef[[ > + int pipe(int *fds); > + int getpid(void); > + long read(int fd, void *buf, size_t count); > + unsigned int alarm(unsigned int seconds); > +]] > + > +local fds = ffi.new('int[2]') > +assert(ffi.C.pipe(fds) == 0) > + > +-- Fail instead of hanging forever if SIGINT does not break > +-- the call. (SIGALRM isn't handled by CLI.) > +ffi.C.alarm(10) > + > +-- The CLI installs the SIGINT handler before the script > +-- starts, so this line is the readiness marker for the test. > +local MARKER = 'CHILD_PID:' > +io.write(MARKER, ffi.C.getpid(), '\n') > +io.flush() > + > +-- Block in read(2) until SIGINT. Without SA_RESTART it returns > +-- EINTR and the CLI runs the Lua hook, which raises > +-- "interrupted!". > +ffi.C.read(fds[0], ffi.new('char[1]'), 1) Why don't use `io.read()` here? Same semantics but additional correlation with the comment in sources. > -- > 2.49.0 > -- Best regards, Sergey Kaplun