Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Date: Wed, 11 Jul 2001 13:19:06 +0200 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: 1.3.2 : Fork + Sleep = problem Message-ID: <20010711131906.K8578@cygbert.vinschen.de> Mail-Followup-To: cygwin AT cygwin DOT com References: <3B4C1BF7 DOT 1807A0C7 AT aspen DOT mine DOT nu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <3B4C1BF7.1807A0C7@aspen.mine.nu>; from adam@aspen.mine.nu on Wed, Jul 11, 2001 at 03:27:19AM -0600 On Wed, Jul 11, 2001 at 03:27:19AM -0600, Adam Stallard wrote: > Here's a short c program that works as expected compiled under some > other unix platforms, but not under my cygwin (1.3.2 , Win 2000) > platform. > > If a call to wait() is added to the code before the sleep command, it > behaves as expected; but I shouldn't have to do that. > > #include > #include > > void main(){ > for(int a=0;a<256;a++){ > pid_t poo=fork(); > if(!poo) > exit(0); > sleep(1); > printf("%d\n",a); > } > } > > This should count up to 255, pausing 1 second between each count; on my > cygwin platform it counts up to 63 with pauses, and then rushes through > the rest of the count. Select, poll, and usleep also fail in this > situation. That's a problem in your application which interferes with a flaw in Cygwin which will be solved in the next version, though. Since you only fork() but never wait(), your children processes become zombies. The zombie list per process is fixed to ... 64 entries. Obviously you don't expect zombies but there's a difference in different UNICES how to handle exiting child processes. The BSD signal model, which is used in Cygwin, only removes zombies after a wait is performed. The SysV model allows to set SIGCHLD to SIG_IGN, which results in removing child processes without creating zombies. This will be supported beginning with Cygwin 1.3.3. However, your application has a major problem in both models. Either you wait() (BSD, Cygwin) or you set SIGCHLD to SIG_IGN (SysV) but ignoring child processes is a NoNo. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Developer mailto:cygwin AT cygwin DOT com Red Hat, Inc. -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/