aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Germain <bnt.germain@gmail.com>2023-08-17 14:56:15 +0200
committerGitHub <noreply@github.com>2023-08-17 14:56:15 +0200
commit4e787d50ae28e2080c1032b57354491be5c4a155 (patch)
tree1dac8ab3fad7a7d5cfd03ddc2595e2b628d4b79a
parentf7245f66295752306ee58c1a9be0ed01b653e347 (diff)
parent3a57fff1e3e9f8f133eaf46f7eb0381a70a323b4 (diff)
downloadlanes-4e787d50ae28e2080c1032b57354491be5c4a155.tar.gz
lanes-4e787d50ae28e2080c1032b57354491be5c4a155.tar.bz2
lanes-4e787d50ae28e2080c1032b57354491be5c4a155.zip
Merge pull request #219 from Mitalie/fix-linux-crash
Prevent crash on linux as non-root
-rw-r--r--src/threading.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/threading.c b/src/threading.c
index 2b68503..2464d03 100644
--- a/src/threading.c
+++ b/src/threading.c
@@ -779,8 +779,8 @@ void THREAD_CREATE( THREAD_T* ref, THREAD_RETURN_T (*func)( void*), void* data,
779{ 779{
780 pthread_attr_t a; 780 pthread_attr_t a;
781 bool_t const change_priority = 781 bool_t const change_priority =
782#if defined(PLATFORM_LINUX) && defined(LINUX_SCHED_RR) 782#ifdef PLATFORM_LINUX
783 sudo && // with sudo, even normal thread must use SCHED_RR 783 sudo && // only root-privileged process can change priorities
784#endif 784#endif
785 (prio != THREAD_PRIO_DEFAULT); 785 (prio != THREAD_PRIO_DEFAULT);
786 786
@@ -887,9 +887,9 @@ void THREAD_CREATE( THREAD_T* ref, THREAD_RETURN_T (*func)( void*), void* data,
887 887
888void THREAD_SET_PRIORITY( int prio) 888void THREAD_SET_PRIORITY( int prio)
889{ 889{
890#if defined PLATFORM_LINUX && defined LINUX_SCHED_RR 890#ifdef PLATFORM_LINUX
891 if( sudo) // only root-privileged process can change priorities 891 if( sudo) // only root-privileged process can change priorities
892#endif // defined PLATFORM_LINUX && defined LINUX_SCHED_RR 892#endif // PLATFORM_LINUX
893 { 893 {
894 struct sched_param sp; 894 struct sched_param sp;
895 // prio range [-3,+3] was checked by the caller 895 // prio range [-3,+3] was checked by the caller