예, 가능합니다. 사실,이 가능성은 pthread_detach()
이 존재하는 주된 이유 중 하나입니다. pthread_detach()
의 POSIX 워드 프로세서 (man pthread_detach
참조)에서 :
It has been suggested that a "detach" function is not necessary; the
detachstate thread creation attribute is sufficient, since a thread
need never be dynamically detached. However, need arises in at least
two cases:
1. In a cancellation handler for a pthread_join() it is nearly essen-
tial to have a pthread_detach() function in order to detach the
thread on which pthread_join() was waiting. Without it, it would
be necessary to have the handler do another pthread_join() to
attempt to detach the thread, which would both delay the cancella-
tion processing for an unbounded period and introduce a new call
to pthread_join(), which might itself need a cancellation handler.
A dynamic detach is nearly essential in this case.
2. In order to detach the "initial thread" (as may be desirable in
processes that set up server threads).
그래서 당신이 제안하고 어떤 기준에 따라 괜찮습니다.
편집 : 그냥 그 더 확인하려면 POSIX description of exec()
미국 : PTHREAD_CREATE_JOINABLE로 설정 detachstate 속성 을 만든 것처럼
이
새로운 프로세스 이미지의 초기 스레드, 조인한다. 당신이 main
의 끝에서 pthread_exit
을하고 있기 때문에
마지막 편집을 위해 소스에 대한 링크를 추가 하시겠습니까? 나는 당신이 여기에서 얻은 것 같아요 : http://pubs.opengroup.org/onlinepubs/009695399/functions/exec.html,하지만 먼저 확인하고 싶었습니다. 훌륭한 대답, 그래! – currysensei
@currysensei : 추가되었습니다! – psmears