From 12a5a5cce98da2c4b1acb0f413ba9e47a7bdd0b9 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Wed, 18 Nov 2020 12:28:11 +0800 Subject: [PATCH] examples: Ignore the default action if app call sigwait Because the configured signo may have the default action(e.g. SIGPIPE), and then will generate the bad side effect before the caller wakeup. Signed-off-by: Xiang Xiao --- examples/buttons/buttons_main.c | 4 ++++ examples/chrono/chrono_main.c | 4 ++++ examples/djoystick/djoy_main.c | 4 ++++ examples/oneshot/oneshot_main.c | 4 ++++ examples/zerocross/zerocross_main.c | 4 ++++ 5 files changed, 20 insertions(+) diff --git a/examples/buttons/buttons_main.c b/examples/buttons/buttons_main.c index e019e5595..ae4837cd7 100644 --- a/examples/buttons/buttons_main.c +++ b/examples/buttons/buttons_main.c @@ -230,6 +230,10 @@ static int button_daemon(int argc, char *argv[]) errcode); goto errout_with_fd; } + + /* Ignore the default signal action */ + + signal(CONFIG_EXAMPLES_BUTTONS_SIGNO, SIG_IGN); #endif /* Now loop forever, waiting BUTTONs events */ diff --git a/examples/chrono/chrono_main.c b/examples/chrono/chrono_main.c index f7b17b6a0..b385280b7 100644 --- a/examples/chrono/chrono_main.c +++ b/examples/chrono/chrono_main.c @@ -177,6 +177,10 @@ static int chrono_daemon(int argc, char *argv[]) goto errout_with_fd; } + /* Ignore the default signal action */ + + signal(BUTTON_SIGNO, SIG_IGN); + /* Now loop forever, waiting BUTTONs events */ for (; ; ) diff --git a/examples/djoystick/djoy_main.c b/examples/djoystick/djoy_main.c index cddd3443c..5649dc159 100644 --- a/examples/djoystick/djoy_main.c +++ b/examples/djoystick/djoy_main.c @@ -190,6 +190,10 @@ int main(int argc, FAR char *argv[]) goto errout_with_fd; } + /* Ignore the default signal action */ + + signal(CONFIG_EXAMPLES_DJOYSTICK_SIGNO, SIG_IGN); + /* Then loop, receiving signals indicating joystick events. */ for (;;) diff --git a/examples/oneshot/oneshot_main.c b/examples/oneshot/oneshot_main.c index 02d7d948d..d5803fcd1 100644 --- a/examples/oneshot/oneshot_main.c +++ b/examples/oneshot/oneshot_main.c @@ -181,6 +181,10 @@ int main(int argc, FAR char *argv[]) printf("Maximum delay is %llu\n", maxus); + /* Ignore the default signal action */ + + signal(CONFIG_EXAMPLES_ONESHOT_SIGNO, SIG_IGN); + /* Loop waiting until the full delay expires */ while (usecs > 0) diff --git a/examples/zerocross/zerocross_main.c b/examples/zerocross/zerocross_main.c index 5f45e5f68..afe78cb4c 100644 --- a/examples/zerocross/zerocross_main.c +++ b/examples/zerocross/zerocross_main.c @@ -112,6 +112,10 @@ int main(int argc, FAR char *argv[]) goto errout_with_fd; } + /* Ignore the default signal action */ + + signal(CONFIG_EXAMPLES_ZEROCROSS_SIGNO, SIG_IGN); + /* Then loop, receiving signals indicating zero cross events. */ for (; ; )