瀏覽代碼

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.
pull/115/head
Peter Kovary 3 年之前
committed by GitHub
父節點
當前提交
772e1198dd
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: 4AEE18F83AFDEB23
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. +3
    -0
      wiringPi/softPwm.c

+ 3
- 0
wiringPi/softPwm.c 查看文件

@@ -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…
取消
儲存