Skip to content
Snippets Groups Projects
Commit c7341a3d authored by Roman Khabibov's avatar Roman Khabibov Committed by Kirill Yukhin
Browse files

console: check on_shutdown() before exit

Add check that on_shutdown() triggers were called before exit,
because in case of EOF or Ctrl+D (no signals) they were ignored.

Closes #4703
parent 4dcba1b5
No related branches found
No related tags found
No related merge requests found
......@@ -902,6 +902,12 @@ main(int argc, char **argv)
if (start_loop)
say_crit("exiting the event loop");
/*
* If Tarantool was stopped using Ctrl+D, then we need to
* call on_shutdown triggers, because Ctrl+D causes not
* any signals.
*/
tarantool_exit(exit_code);
/* freeing resources */
tarantool_free();
return exit_code;
......
-- test-run result file version 2
env = require('test_run')
| ---
| ...
fio = require("fio")
| ---
| ...
test_run = env.new()
| ---
| ...
--
-- gh-4703: Make sure that on_shutdown triggers are executed after
-- EOF.
--
file_name = "on_shutdown_triggered.txt"
| ---
| ...
test_run:cmd("setopt delimiter ';'");
| ---
| - true
| ...
on_shutdown_cmd = "box.ctl.on_shutdown(function() local fio = require('fio') "..
"fio.open('"..file_name.."', "..
"{'O_CREAT', 'O_TRUNC', 'O_WRONLY'}, 777):close() end)";
| ---
| ...
test_run:cmd("setopt delimiter ''");
| ---
| - true
| ...
server = io.popen('tarantool -i', 'w')
| ---
| ...
server:write(on_shutdown_cmd)
| ---
| - true
| ...
server:close()
| ---
| - true
| ...
fio.path.lexists(file_name) == true
| ---
| - true
| ...
os.remove(file_name)
| ---
| - true
| ...
env = require('test_run')
fio = require("fio")
test_run = env.new()
--
-- gh-4703: Make sure that on_shutdown triggers are executed after
-- EOF.
--
file_name = "on_shutdown_triggered.txt"
test_run:cmd("setopt delimiter ';'");
on_shutdown_cmd = "box.ctl.on_shutdown(function() local fio = require('fio') "..
"fio.open('"..file_name.."', "..
"{'O_CREAT', 'O_TRUNC', 'O_WRONLY'}, 777):close() end)";
test_run:cmd("setopt delimiter ''");
server = io.popen('tarantool -i', 'w')
server:write(on_shutdown_cmd)
server:close()
fio.path.lexists(file_name) == true
os.remove(file_name)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment