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

```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()** изважда от горната част на стека съдържащ манипулатори за почистване и по избор я изпълнява, ако изпълнението е различно от нула.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dimitar-minchev.gitbook.io/linux-system-programming/09_threads_sync/02_threads_exit_managing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
