Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-developers-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin-developers AT sources DOT redhat DOT com Date: Fri, 18 May 2001 22:11:07 -0400 From: Christopher Faylor To: cygwin-developers AT cygwin DOT com Subject: pthread gotchas Message-ID: <20010518221107.A12195@redhat.com> Reply-To: cygwin-developers AT cygwin DOT com Mail-Followup-To: cygwin-developers AT cygwin DOT com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.11i (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