Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Yes, this is possible. Indeed, this possibility is one of the main reasons why <code>pthread_detach()</code> exists. From the POSIX docs for <code>pthread_detach()</code> (see <code>man pthread_detach</code>):</p> <pre><code> 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). </code></pre> <p>So what you're proposing is fine according to the standards.</p> <p><strong>Edit:</strong> Just to confirm that further, the <a href="http://pubs.opengroup.org/onlinepubs/009695399/functions/exec.html" rel="nofollow noreferrer">POSIX description of <code>exec()</code></a> states:</p> <blockquote> <p>The initial thread in the new process image shall be joinable, as if created with the detachstate attribute set to PTHREAD_CREATE_JOINABLE.</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload