> For the complete documentation index, see [llms.txt](https://dimitar-minchev.gitbook.io/linux-system-programming/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dimitar-minchev.gitbook.io/linux-system-programming/09_threads_sync/02_threads_exit_managing.md).

# Управление на изход от нишка

```c
#include<pthread.h>
void pthread_cleanup_push(void (*routine)(void *), void *arg);
void pthread_cleanup_pop(int execute);
```

* Функцията **pthread\_cleanup\_push()** добавя в горната част на стека съдържащ манипулатори за почистване на нишки. Когато манипулатора бъде извикан за изпълнение по-късно, arg променливата ще бъде подадена като аргумент.
* Функцията **pthread\_cleanup\_pop()** изважда от горната част на стека съдържащ манипулатори за почистване и по избор я изпълнява, ако изпълнението е различно от нула.
