This is the mail archive of the cygwin-developers@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

pthread gotchas


(I'll bet that this got Robert's attention)

Just to be clear up front, the gotchas I'm talking about are my gotchas.
There were apparently some aspects of the way that pthreads work that I
was not familiar with.

I am looking into finally getting signals working in a multi-threaded
enviroment given Corinna's recent problems with cygrunsrv.  So, I
wrote a program which forked, started a separate thread, and then
called waitpid().  I wanted to see how a SIGINT with a signal handler
would work with pthreads.  I ran the program on linux.

I was surprised to find out that waitpid failed in this scenario.
Apparently this was due to the fact that fork was called in the
main thread and waitpid was called in a secondary thread.

I hadn't anticipated this behavior when I wrote the process handling
years ago, even though I thought I was cleverly making things thread
safe.

So, my question is, is this standard pthread behavior?  I know that
linux's pthread implementation has been through a couple of iterations.
I don't know if it is fully compliant or not.

Is there other stuff that will work this way as well?  For instance,
will strtok (not strtok_r) work right?  I'm wonder how many of my
misguided perceptions I need to examine.

I've searched the net for a pthreads tutorial but the only ones I've
been able to find are really basic.  Does anyone have a recommendation
for a good reference?

cgf


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]