Problem with atoi in pthreads
I'm having a unique problem using atoi() or strtol() in a newly created pthread. I have used pthreads extensively in the past, but am new to using them on Linux. We are running Red Hat 8.0.
In a simple Unit Test, I use atoi to convert a numeric string (let's say "36") to an int. This simple line 'num=atoi("36")' works fine in the main process, but the same line of code running in a pthread crashes the process.
The thread is created calling pthread_create and have set the attributes to
inheritsched = EXPLICIT_SCHED
detachstate = CREATE_JOINABLE
scope = SCOPE_SYSTEM
sched_policy = SCHED_FIFO
priority = 20
After a cout in the new thread just to show that is was created, I call num=atoi("36") and I get a segmentation fault. Using the debugger has been no help.
The problem orinally arose when we were trying to read in an environment setting and converting it, but now we are down to this very simple test to figure out our problem.