patacongo commented on PR #9632:
URL: https://github.com/apache/nuttx/pull/9632#issuecomment-1611457813

   > Taking into account that `The pthread_exit() function cannot return to its 
caller.`, so 3 lines below `pthread_exit(NULL);` will never be executed.
   
   Which could be as intended.  I would need to look at the test driver to see 
what the expected behavior is.
   
   >2.  pthread_exit just terminate the calling thread, but the program will 
terminate too if this is the last thread in the calling process
   
   That is the NuttX behavior, but I don't think it is the Linux behavior.  I 
don't have good references but there is this stackoverflow response:
   
   #include <stdio.h>
   #include <stdlib.h>
   #include <pthread.h>
   
       int main(int argc, char *argv[])
       {
           printf("-one-\n");
           pthread_exit(NULL);
           printf("-two-\n");
       }
   
   According to the post, the program never terminates, it simply freezes.  The 
first printf is printed , but the second one is not .  
https://stackoverflow.com/questions/3559463/is-it-ok-to-call-pthread-exit-from-main
   
   "It's fine to use pthread_exit in main. When pthread_exit is used, the main 
thread will stop executing and will remain in zombie(defunct) status until all 
other threads exit. ".  Interesting discussion and more examples follow.
   


-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

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

Reply via email to