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 E97A16EC44; Sun, 15 Nov 2026 23:40:04 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E97A16EC44 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1794775205; bh=J8xLiziw7hLNJRXhNXOzcTqNnYOj5ylloSSFRBJ/rfM=; 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=llbDnwkEz2axl0/qB84g6py9CvsugJWsCEbrhXdo3d5eIP6AoJ5fosv2gDKxISPKf WDefz1aFECaGcdc3qPP1GV///cpgj0Jm1WqTz4mPbekRx8duwpzo52eoPHET8Dhr6N gdV5s01yMlCXRXxdAL6dn5FOA3N0WHHANIZvnLo0= Received: from send103.i.mail.ru (send103.i.mail.ru [89.221.237.198]) (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 252466EC44 for ; Sun, 15 Nov 2026 23:40:04 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 252466EC44 Received: by exim-smtp-f7c4f5855-pvjld with esmtpa (envelope-from ) id 1xSh18-00000000JTo-3r86; Sun, 15 Nov 2026 23:40:03 +0300 Message-ID: Date: Sun, 15 Nov 2026 23:40:02 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Sergey Bronnikov References: <68d8da9f72cbf7237b0e21f9c643789d36fa82a8.1793574664.git.e.temirgaleev@tarantool.org> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD93F98A09C3FD4AFA2F174A1157A02A8FC19196B6A03AB225B182A05F5380850401108E1F58BD597CF3DE06ABAFEAF6705F106C788BA631C3FEBE3EF12CE9E04F1B6BD4AB1FA1FD0A3 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7CA8E915ACC910FBDEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB553375660DEDE30684C59E5B888F997CED9E059964AFB71C9BAE8187F913D1CFD784B83E389733CBF5DBD5E9D5E8D9A59859A8B64854413538E1713FCC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB8090A508E0FED6299176DF2183F8FC7C031128297CE6726AFCD04E86FAF290E2DB606B96278B59C421DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6B49244D26B9D679D089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-B7AD71C0: 6FEFE4C63DFE2D851629A3278334FCEC2AD323669803AD9FE6E38E9349F0B966CB64D53426D5185EB66839FCB541B5EF X-C1DE0DAB: 0D63561A33F958A5890092C2447C005B5002B1117B3ED696AEF7841EEACA58047E0012C66AE17B00823CB91A9FED034534781492E4B8EEADB1D70E2111C441FFBDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE1918E10F71CB4DF9F962AFAD3E4DDF5968D25B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D6591DA401E3A4ADEB6A38FAA4C2A31D6F7C1FCC5B8BA2E0EB6A08F1458A237EB1BDB581EC645EC547DDB8341EE9D5BE9A0AC22CC25BB610309B6765B5596399D146715046C9139A8424C7CEAA0681F5848F4C41F94D744909CEEF9E35A692215F79327F81E6EEE0AEB67A0F9F91F029B6AF33F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXOcIETfglQORZ0zpDET4Zrk3igikrdHlWJPXcCxX0vFz3KofJT2Itw4= X-Mailru-Sender: 015BA6FC0EFA223A63A6570A1A031285C211EFAB5173C429B951B70A5BD4BD8E6BC2E798DB75644CE11A6E312C87D21DE62B12C1FE0372A178274A4A9E9E44FD2A114EDA040D8818F01FF9DF31C397A372D6B4FCE48DF648AE208404248635DF 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: Evgeniy Temirgaleev via Tarantool-patches Reply-To: Evgeniy Temirgaleev Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, Sergey! Thanks for review! Please, see my fixes and answers. Also, tap:diag() calls in the test unit was fixed (the format string passed explicitly). The changes were force pushed to the branch. On 11/12/26 12:31 PM, Sergey Bronnikov wrote: > Hi, Evgeniy, > > thanks for the fixes! See my comments below. > > Sergey > > On 11/2/26 02:59, Evgeniy Temirgaleev wrote: >> From: Mike Pall >> >> (cherry picked from commit 423ac2144b0447c925596f4d93e073ce501ed4e1) >> 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 >> +-- SIGINT on a blocking system call (read(), waitpid(), etc.). >> +-- >> +-- The test runs luajit CLI with a script, which prints it's PID >> +-- 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 > s/the the/the/ (typo in the patch on the branch) Fixed. >> +-- 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. >> +-- Without a patch (SA_RESTART flag is present for SIGINT >> +-- handler) read() call is restarted, the test and the child is >> +-- 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, > The skip reason "Disabled due to Tarantool uses it's own signal > handling" -> > "Disabled because Tarantool uses its own signal handling". Fixed. >> +  ['Disabled on POSIX nonconformant OS'] = jit.os ~= 'BSD' and > The "Disabled on POSIX nonconformant OS" reads as if a POSIX system did not > conform, while the check is a whitelist of supported `jit.os` values; maybe > "Disabled on non-POSIX systems"? Thanks! Used your suggestion. >> +                                           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) > The suite skips signal/timing-sensitive tests under Valgrind via > `os.getenv('LUAJIT_TEST_USE_VALGRIND')`, while this one still does not. The > Valgrind CI job runs the whole `tarantool-tests` suite, and here the > child is > spawned through `luacmd()`, so it is wrapped in Valgrind as well, which > makes > startup and signal delivery slower. I could not check this locally (no > Valgrind > in this environment). Is running this test under Valgrind intentional, > or would > the usual skip condition be safer? I tried to run CI several times and can't reproduce a fail in the Valgrind environment with the test. I shall add the skip if you will insist. --- >> 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') >> + > > the version at the branch contains a comment missed here: > > > +-- The script runs via 'popen()' with closed pipe read-end, > > +-- and the stdin is not guaranteed to be connected somewhere. > > +-- Reading from it may result in EOF. > > Maybe: "The child's stdin is inherited from the test process and may be > `/dev/null` or closed, so a read from it can return EOF immediately. > Hence a new > pipe is created and its read end will block."? More detailed description added. > > Also `read-end` -> `read end`. Fixed. > >> +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) --- 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 index 0e444dee..9d1500c2 100644 --- 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 @@ -5,7 +5,7 @@ local tap = require('tap') -- -- The test runs LuaJIT CLI with a script, which prints its PID -- as a ready marker and blocks on a read() call. After the --- the child's PID number is read from child's pipe, the test +-- child's PID number is read from child's pipe, the test -- 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 @@ -17,11 +17,11 @@ local tap = require('tap') 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, - ['Disabled on POSIX nonconformant OS'] = jit.os ~= 'BSD' and - jit.os ~= 'Linux' and - jit.os ~= 'OSX' and - jit.os ~= 'POSIX', + ["Disabled because Tarantool uses its own signal handling"] = _TARANTOOL, + ['Disabled on non-POSIX systems'] = jit.os ~= 'BSD' and + jit.os ~= 'Linux' and + jit.os ~= 'OSX' and + jit.os ~= 'POSIX', }) local ffi = require('ffi') @@ -41,7 +41,7 @@ local RMARKER = '^' .. MARKER .. '(%d+)$' -- 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 lines_for_diag = {} local pid, line repeat line = proc:read('*l') @@ -52,7 +52,7 @@ repeat end until line == nil or pid ~= nil if pid == nil then - test:diag(table.concat(lines_for_diag, '\n')) + test:diag('child output: %s', table.concat(lines_for_diag, '\n')) end assert(pid ~= nil, 'the child process must report its PID') @@ -60,6 +60,6 @@ local res = ffi.C.kill(pid, SIGINT) assert(res == 0, 'SIGINT delivery failed') local output = proc:read('*a') proc:close() -test:diag(output) +test:diag('child output: %s', output) 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 index 6d1c0913..2b054ac4 100644 --- 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 @@ -7,10 +7,12 @@ ffi.cdef[[ unsigned int alarm(unsigned int seconds); ]] --- The script runs via 'popen()' with closed pipe read-end, --- and the stdin is not guaranteed to be connected somewhere. --- Reading from it may result in EOF. --- So, establish the new pipe, which read-end would block. +-- The script runs via 'popen("r")' by the test process and the +-- child's stdout is connected to the parent's pipe read, but +-- the child's stdin is inherited from the test process and +-- may be `/dev/null` or closed, so a read from it can return +-- EOF immediately. +-- Hence a new pipe is created and its read end will block. local fds = ffi.new('int[2]') assert(ffi.C.pipe(fds) == 0) -- -- Best regards, Evgeniy Temirgaleev