mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 01:36:39 +08:00
Call pthread_attr_destroy even if pthread_create failed
As suggested in
63bfab9975 (commitcomment-66542462)
Also, check for errors.
This commit is contained in:
parent
63d7386a36
commit
2f5edfd617
|
@ -362,10 +362,14 @@ bool make_detached_pthread(void *(*func)(void *), void *param) {
|
|||
err = pthread_create(&thread, &thread_attr, func, param);
|
||||
if (err == 0) {
|
||||
FLOGF(iothread, "pthread %d spawned", thread);
|
||||
pthread_attr_destroy(&thread_attr);
|
||||
} else {
|
||||
perror("pthread_create");
|
||||
}
|
||||
int err2 = pthread_attr_destroy(&thread_attr);
|
||||
if (err2 != 0) {
|
||||
perror("pthread_attr_destroy");
|
||||
err = err2;
|
||||
}
|
||||
} else {
|
||||
perror("pthread_attr_setdetachstate");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user