| 48 | |
| 49 | #ifdef CONFIG_FILE_STREAM |
| 50 | static void task_uninit_stream(FAR struct task_group_s *group) |
| 51 | { |
| 52 | FAR struct streamlist *list; |
| 53 | FAR struct file_struct *stream; |
| 54 | FAR sq_entry_t *curr; |
| 55 | FAR sq_entry_t *next; |
| 56 | |
| 57 | DEBUGASSERT(group && group->tg_info); |
| 58 | list = &group->tg_info->ta_streamlist; |
| 59 | stream = list->sl_std; |
| 60 | |
| 61 | /* Destroy the mutex and release the filelist */ |
| 62 | |
| 63 | nxmutex_destroy(&list->sl_lock); |
| 64 | |
| 65 | /* Destroy stdin, stdout and stderr stream */ |
| 66 | |
| 67 | #ifndef CONFIG_STDIO_DISABLE_BUFFERING |
| 68 | nxrmutex_destroy(&stream[0].fs_lock); |
| 69 | nxrmutex_destroy(&stream[1].fs_lock); |
| 70 | nxrmutex_destroy(&stream[2].fs_lock); |
| 71 | #endif |
| 72 | |
| 73 | /* Release each stream in the list */ |
| 74 | |
| 75 | sq_for_every_safe(&list->sl_queue, curr, next) |
| 76 | { |
| 77 | stream = container_of(curr, struct file_struct, fs_entry); |
| 78 | |
| 79 | #ifndef CONFIG_STDIO_DISABLE_BUFFERING |
| 80 | /* Destroy the mutex that protects the IO buffer */ |
| 81 | |
| 82 | nxrmutex_destroy(&stream->fs_lock); |
| 83 | #endif |
| 84 | |
| 85 | /* Release the stream */ |
| 86 | |
| 87 | #ifdef CONFIG_BUILD_KERNEL |
| 88 | /* If the exiting group is unprivileged, then it has an address |
| 89 | * environment. Don't bother to release the memory in this case... |
| 90 | * There is no point since the memory lies in the user heap which |
| 91 | * will be destroyed anyway. But if this is a privileged group, |
| 92 | * when we still have to release the memory using the kernel |
| 93 | * allocator. |
| 94 | */ |
| 95 | |
| 96 | if ((group->tg_flags & GROUP_FLAG_PRIVILEGED) != 0) |
| 97 | #endif |
| 98 | { |
| 99 | group_free(group, stream); |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | #endif |
| 104 | |
| 105 | /**************************************************************************** |
no test coverage detected