You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/06/01 13:05:02 UTC

[GitHub] [incubator-nuttx-apps] acassis commented on a change in pull request #743: add SIGTERM handling in leds example

acassis commented on a change in pull request #743:
URL: https://github.com/apache/incubator-nuttx-apps/pull/743#discussion_r643068475



##########
File path: examples/leds/leds_main.c
##########
@@ -170,16 +197,25 @@ static int led_daemon(int argc, char *argv[])
           goto errout_with_fd;
         }
 
-      usleep(500*1000L);
+      usleep(500 * 1000L);
+    }
+
+  /* treats signal termination of the task */
+
+  if (g_led_daemon_started == false)
+    {
+      /* task terminated by a SIGTERM */
+
+      exit(EXIT_SUCCESS);

Review comment:
       I think you don't need to include this block, when the execution exits the while() the g_led_daemon_started will be false for sure. Just let the default flow to flow, closing the fd "manually" etc

##########
File path: examples/leds/leds_main.c
##########
@@ -170,16 +197,25 @@ static int led_daemon(int argc, char *argv[])
           goto errout_with_fd;
         }
 
-      usleep(500*1000L);
+      usleep(500 * 1000L);
+    }
+
+  /* treats signal termination of the task */
+
+  if (g_led_daemon_started == false)
+    {
+      /* task terminated by a SIGTERM */
+
+      exit(EXIT_SUCCESS);
     }
 
-errout_with_fd:
-  close(fd);
+  errout_with_fd:
+    close(fd);
 
-errout:
-  g_led_daemon_started = false;
+  errout:
+    g_led_daemon_started = false;

Review comment:
       These lines:
     errout:
       g_led_daemon_started = false;
   
   now are redundant, you can remove it




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org