Skip to content

Commit

Permalink
tests/iio{read,write}dev: Fix unkillable process
Browse files Browse the repository at this point in the history
Register the signal handlers before everything else. Otherwise, the
signals might be sent to any thread that might be created by libiio, or
its dependencies, making these programs only killable by a signal 9.

Signed-off-by: Paul Cercueil <[email protected]>
  • Loading branch information
pcercuei committed Apr 1, 2022
1 parent d03eb96 commit 60de6b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tests/iio_readdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ int main(int argc, char **argv)

argw = dup_argv(MY_NAME, argc, argv);

setup_sig_handler();

ctx = handle_common_opts(MY_NAME, argc, argw, MY_OPTS, options, options_descriptions);
opts = add_common_options(options);
if (!opts) {
Expand Down Expand Up @@ -314,8 +316,6 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}

setup_sig_handler();

dev = iio_context_find_device(ctx, argw[optind]);
if (!dev) {
fprintf(stderr, "Device %s not found\n", argw[optind]);
Expand Down
4 changes: 2 additions & 2 deletions tests/iio_writedev.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ int main(int argc, char **argv)

argw = dup_argv(MY_NAME, argc, argv);

setup_sig_handler();

ctx = handle_common_opts(MY_NAME, argc, argw, MY_OPTS, options, options_descriptions);
opts = add_common_options(options);
if (!opts) {
Expand Down Expand Up @@ -333,8 +335,6 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}

setup_sig_handler();

dev = iio_context_find_device(ctx, argw[optind]);
if (!dev) {
fprintf(stderr, "Device %s not found\n", argw[optind]);
Expand Down

0 comments on commit 60de6b9

Please sign in to comment.