strtok function thread safety
c, linux, strtok, thread-safety
Solution
`strtok()` is not reentrant so it should not be used from threaded applications, use `strtok_r()` instead.
Problem
I have been spending some time in debugging a programme which gives segmentation fault. The bug is quite indeterministic and intermittent, which is annoying. I narrowed it down to the calling of `strtok()`. I suspect that it is the calling of `strtok()` to split string in two different threads that causes the segmentation fault. Can I call `strtok()` in two different threads? Thanks.