POSIX port clean shutdown

Hello,

I have noticed some unexpected behavior when running vTaskEndScheduler() with the FreeRTOS POSIX port. Programs that invoke vTaskStartScheduler() followed by vTaskEndScheduler() do not exit cleanly or at all.

I have created a program illustrating this behavior that I would like to be considered to add as a test case. Here is a link to the GitHub repository containing the test:

github. com/bdesterBE/freertos_posix_shutdown
(as a new user I cannot post links, but please just remove the space before ‘com’ in the link)

I also want to know if I should report this as a bug on GitHub tracker. I am currently looking into seeing if I can resolve the issue myself.

Please let me know if you have any information regarding this issue, including whether the test case is reflective of proper usage. If this is a valid test case, please let me know where it can be added to the FreeRTOS repository.

Thanks,
Brandon

This example code should include the following block after calling vTaskEndScheduler()

if( t1.joinable() )
{
    t1.join();
}

If t1 goes out of scope,~std::thread() will call std::terminate() if the thread is still joinable.

Besides that, I do not know whether the POSIX port specifies what threads not managed by the kernel can and cannot do. This may be a case of unspecified behavior in the POSIX port allowed by thread creation. The intention of vTaskEndScheduler() was to allow a FreeRTOS task to return control to the application as-if vTaskBeginScheduler() returned.