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)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 14 Nov 2019 22:49:45 +0000 (17:49 -0500)
commit851802b13043e82096e7f5f9ea6a0f0b307d778b
treedb63e1917112e95b584fbf5c6b8e962b60292e6e
parent622d120665858246520982b81f59f9723fe6fa47
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.025623 seconds and 4 git commands to generate.