cli: exit with status 2 when interrupted by SIGINT
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Tue, 29 Oct 2019 21:45:09 +0000 (17:45 -0400)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Tue, 5 Nov 2019 21:47:53 +0000 (16:47 -0500)
commitb5cd7d6593ad0dba510172268777a521442387d7
tree7b6159beaf426ce97078352c16b55a321ffdd47c
parent4dc8af4341c8068e9aca67f6d11b15b58e06040a
cli: exit with status 2 when interrupted by SIGINT

With this commit, users of the CLI issuing a ctrl+c to interrupt a
running graph will not get an error cause stack printed to stderr.
Instead, they will now simply get a non-zero exit status to signify that
the execution of the command did not complete as expected.

We preferred this approach, because we consider it unexpected that a
user who willingly pressed ctrl+c to stop the command ends up getting an
error cause stack printed to the CLI.
As the execution did not complete normally, we also did not want the
command to exit with status 0 in such cases. Exiting with status code 1
was also not appropriate as it is typically used to signify an error.

In sum, the middle ground we found, is to exit with status code 2 and
not print an error message.

This commit adds tests to confirm that the right exit status is produced
by the CLI when a graph is interrupted, is erroring, or is returning
successfully. To do this, this commit adds a custom Python source
component class that takes as parameter the name of the scenario to
produce during its iterator's first `_next()` call. The iterator then
does the needful to put the graph in the right condition. We then test
if the CLI exits with the expected status.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I82a451b24240be6fb2256ce681685ba02b73600f
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2308
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
src/cli/babeltrace2.c
tests/Makefile.am
tests/cli/test_exit_status [new file with mode: 0755]
tests/data/cli/exit_status/bt_plugin_test_cli_exit_status.py [new file with mode: 0644]
This page took 0.024599 seconds and 4 git commands to generate.