You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ag...@apache.org on 2020/11/28 11:19:47 UTC

[incubator-nuttx-apps] 01/02: examples: Ignore the default action if app call sigwait

This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit 12a5a5cce98da2c4b1acb0f413ba9e47a7bdd0b9
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Wed Nov 18 12:28:11 2020 +0800

    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 <xi...@xiaomi.com>
---
 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 e019e55..ae4837c 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 f7b17b6..b385280 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 cddd344..5649dc1 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 02d7d94..d5803fc 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 5f45e5f..afe78cb 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 (; ; )