Tarantool development patches archive
 help / color / mirror / Atom feed
From: Evgeniy Temirgaleev via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Sergey Bronnikov <sergeyb@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH luajit v3 2/2] Improve CLI signal handling on POSIX.
Date: Sun, 15 Nov 2026 23:40:02 +0300	[thread overview]
Message-ID: <c4a859aa-5839-44fb-97c6-99b3702b8df4@tarantool.org> (raw)
In-Reply-To: <be1b4664-d600-43cd-b635-70e459cc318e@tarantool.org>

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 <mike>
>>
>> (cherry picked from commit 423ac2144b0447c925596f4d93e073ce501ed4e1)
<snipped>
>> 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.

---

<snipped>

>> 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


      reply	other threads:[~2026-11-15 20:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-01 23:59 [Tarantool-patches] [PATCH luajit v3 0/2] " Evgeniy Temirgaleev via Tarantool-patches
2026-11-01 23:59 ` [Tarantool-patches] [PATCH luajit v3 1/2] test: refactored utils.exec.makecmd Evgeniy Temirgaleev via Tarantool-patches
2026-11-03 11:55   ` Sergey Kaplun via Tarantool-patches
2026-11-05 15:24     ` Evgeniy Temirgaleev via Tarantool-patches
2026-11-06 14:37   ` Sergey Bronnikov via Tarantool-patches
2026-11-09  2:16     ` Evgeniy Temirgaleev via Tarantool-patches
2026-11-01 23:59 ` [Tarantool-patches] [PATCH luajit v3 2/2] Improve CLI signal handling on POSIX Evgeniy Temirgaleev via Tarantool-patches
2026-11-03 12:14   ` Sergey Kaplun via Tarantool-patches
2026-11-08 22:00     ` Evgeniy Temirgaleev via Tarantool-patches
2026-11-12  9:31   ` Sergey Bronnikov via Tarantool-patches
2026-11-15 20:40     ` Evgeniy Temirgaleev via Tarantool-patches [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c4a859aa-5839-44fb-97c6-99b3702b8df4@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=e.temirgaleev@tarantool.org \
    --cc=sergeyb@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH luajit v3 2/2] Improve CLI signal handling on POSIX.' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox