mirror of
https://github.com/clockworkpi/WiringPi.git
synced 2025-12-12 16:08:49 +01:00
Return error from softPwmCreate if pthread_create fails
If `pthread_create` fails, `newPin` will never get reset to -1 and process would hang. This change will return from `softPwmCreate` immediately if `pthread_create` returns a non-zero value and avoid hanging forever.
This commit is contained in:
parent
afddd8c504
commit
772e1198dd
@ -153,6 +153,9 @@ int softPwmCreate (int pin, int initialValue, int pwmRange)
|
||||
newPin = pin ;
|
||||
res = pthread_create (&myThread, NULL, softPwmThread, (void *)passPin) ;
|
||||
|
||||
if (res != 0)
|
||||
return res ;
|
||||
|
||||
while (newPin != -1)
|
||||
delay (1) ;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user