Thread safety with errno

17 views
Skip to first unread message

Guy Morand

unread,
Dec 14, 2023, 10:41:53 AM12/14/23
to libm...@googlegroups.com
Hi libmodus mailing list!

I think I have found my answer but I'm still asking to double check.

From https://github.com/stephane/libmodbus/issues/246, a ``modbus_t``
is not thread safe and should be only access by a single thread.

My worries is about errno. By checking the code it seems that it is
using ``<errno.h>`` from the standard C library. At least under Linux,
from ``man 3 errno``:
"errno is thread-local; setting it in one thread does not affect its
value in any other thread."

So I should be safe as long as I access ``modbus_t`` from the same
thread. Could you confirm?

Thanks for your enlightenment!

Best regards,

Guy Morand

--
bytes at work
Technoparkstrasse 7
CH-8406 Winterthur
Switzerland

phone: +41 52 213 79 79
Reply all
Reply to author
Forward
0 new messages