-
Notifications
You must be signed in to change notification settings - Fork 376
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tarantool console quits if you type Ctrl+C. This patch fixes console behavior on sending SIGINT. Console discards the current input on typing Ctrl+C and invites user to the new line. In daemon mode the process will exit after receiving SIGINT. Fixes #2717
- Loading branch information
Showing
2 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env tarantool | ||
|
||
local fiber = require('fiber') | ||
local tap = require('tap') | ||
local popen = require('popen') | ||
|
||
-- | ||
-- gh-2717: tarantool console quit on sigint | ||
-- | ||
|
||
local TARANTOOL_PATH = arg[-1] | ||
|
||
local res = tap.test('gh-2717', function(test) | ||
print(TARANTOOL_PATH) | ||
|
||
test:plan(2) | ||
local prompt = 'tarantool>' | ||
local ph = popen.shell(TARANTOOL_PATH .. ' -i', 'r') | ||
assert(ph.pid, 'popen error while executing ' .. TARANTOOL_PATH) | ||
|
||
fiber.sleep(0.5) | ||
ph:signal(popen.signal.SIGINT) | ||
fiber.sleep(0.5) | ||
|
||
local output = ph:read() | ||
test:like(ph:info().status.state, popen.state.ALIVE, 'process is still alive after SIGINT ') | ||
|
||
ph:close() | ||
print(output) | ||
test:like(output, prompt .. ' \n' .. prompt, 'SIGINT doesn\'t kill tarantool in interactive mode ') | ||
ph:close() | ||
end) | ||
os.exit(res and 0 or 1) |