[LINUX] About the return value of pthread_mutex_init ()


I checked the return value of the library function pthread_mutex_init ().


At work, I was looking at the code written by BP (Business Partner). Then check the return value of pthead_mutex_init ()


   if (r == -1)
      //Error handling

Was written.

I "... -1 !?"

Result of investigation

It varies depending on the page, but it was roughly the following three.

-Pthread_mutex_init () always returns 0. or -Pthread_mutex_init () returns 0 when normal and -1 when abnormal. or -Pthread_mutex_init () returns 0 when normal and nonzero when abnormal.

Is it environment-dependent?


For the time being, regarding the check of the return value


   if (r != 0)
      //Error handling

I wonder if it should be non-zero.

Recommended Posts

About the return value of pthread_mutex_init ()
About the return value of the histogram.
Watch out for the return value of __len__
About the ease of Python
About the components of Luigi
About the features of Python
The story that the return value of tape.gradient () was None
Find the definition of the value of errno
Check the return value using PEP 380
About the basic type of Go
About the upper limit of threads-max
About the behavior of yield_per of SqlAlchemy
About the size of matplotlib points
About the basics list of Python basics
About the behavior of enable_backprop of Chainer v2
About the virtual environment of python version 3.7
About the arguments of the setup function of PyCaret
About the Normal Equation of Linear Regression
Get the value of the middle layer of NN
Make the default value of the argument immutable
About the test
Get the return value of an external shell script (ls) with python3
About the queue
About the accuracy of Archimedean circle calculation method
About the behavior of copy, deepcopy and numpy.copy
About the X-axis notation of Matplotlib bar graphs
About the processing speed of SVM (SVC) of scikit-learn
The value of pyTorch torch.var () is not distributed
Try singular value decomposition of the daimyo matrix
A note about the python version of python virtualenv
Find the divisor of the value entered in python
About the development contents of machine learning (Example)
[Note] About the role of underscore "_" in Python
About the behavior of Model.get_or_create () of peewee in Python
Search by the value of the instance in the list
About the behavior of Queue during parallel processing
About the * (asterisk) argument of python (and itertools.starmap)
[Python] Summary of functions that return the index that takes the closest value in the array
The beginning of cif2cell
A memorandum about the warning of the pylint output result
[Python of Hikari-] Chapter 06-02 Function (argument and return value 1)
About all of numpy
Around the place where the value of Errbot is stored
Return one-hot encoded features to the original category value
The meaning of self
[Python] Calculate the average value of the pixel value RGB of the object
Return value of quit ()-Is there anything returned by the "function that ends everything"?
About MultiIndex of pandas
the zen of Python
Think about the next generation of Rack and WSGI
About testing in the implementation of machine learning models
Get the return code of the Python script from bat
About the inefficiency of data transfer in luigi on-memory
[C language] [Linux] Get the value of environment variable
Take the value of SwitchBot thermo-hygrometer with Raspberry Pi
Make the default value of the argument immutable (article explanation)
The story of sys.path.append ()
Log the value of SwitchBot thermo-hygrometer with Raspberry Pi
[Golang] Specify an array in the value of map
About the Unfold function
About the service command