View Issue Details

IDProjectCategoryView StatusLast Update
00019501003.1(2024)/Issue8System Interfacespublic2025-10-23 15:57
Reporterelahav Assigned To 
PrioritynormalSeverityEditorialTypeEnhancement Request
Status ClosedResolutionRejected 
NameElad Lahav
OrganizationBlackBerry QNX
User Reference
SectionSystem Interfaces
Page NumberN/A
Line NumberN/A
Interp Status---
Final Accepted Text
Summary0001950: Create a detached thread with a function that returns void
DescriptionIt is a fairly common pattern (especially in embedded systems) to create a thread that runs an infinite loop, with option to return. Such a thread can be created as detached (PTHREAD_CREATE_DETACHED), as there is no reason to call pthread_join() on a thread that doesn't return.
The problem is that pthread_create() takes a function that returns void*. This causes problems with several standards, such as ISO C and MISRA:

void *thread_func(void *arg)
{
    for (;;) {
        ...
    }
}

The function must return a value, but cannot have a return statement after (or within) the for loop, as that would be dead code. The function cannot be marked as no-return, because of its type. If the type is changed to void, the function cannot be passed to pthread_create() without illegal (according to the standard) casts.
Desired ActionProposing a new function

int pthread_create_detached(pthread_t *restrict thread,
       const pthread_attr_t *restrict attr,
       void (*start_routine)(void*), void *restrict arg);

The function is identical to pthread_create(), except for the start_routine signature, and that it always sets the PTHREAD_CREATE_DETACHED attribute.
TagsNo tags attached.

Activities

eblake

2025-10-23 15:56

manager   bugnote:0007290

While the idea may have merit, the Austin Group is required to consider existing implementations in the standardization process. We advise attempting to get at least one existing libc implementation to implement the proposal, possibly under a slightly different name like pthread_create_detached_np to minimize issues with future namespace changes, at which point it will be easier to augment POSIX to standardize the interface if a sponsor for the new interface is found. For now, this issue is being rejected for lack of implementation practice.

Issue History

Date Modified Username Field Change
2025-10-10 22:50 elahav New Issue
2025-10-23 15:56 eblake Note Added: 0007290
2025-10-23 15:57 eblake Status New => Closed
2025-10-23 15:57 eblake Resolution Open => Rejected
2025-10-23 15:57 eblake Interp Status => ---