From stdcxx-dev-return-2403-apmail-incubator-stdcxx-dev-archive=incubator.apache.org@incubator.apache.org Thu Nov 30 19:47:01 2006 Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 27800 invoked from network); 30 Nov 2006 19:47:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 30 Nov 2006 19:47:01 -0000 Received: (qmail 38360 invoked by uid 500); 30 Nov 2006 19:47:10 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 38348 invoked by uid 500); 30 Nov 2006 19:47:10 -0000 Mailing-List: contact stdcxx-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-dev@incubator.apache.org Received: (qmail 38337 invoked by uid 99); 30 Nov 2006 19:47:10 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Nov 2006 11:47:10 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [208.30.140.160] (HELO moroha.quovadx.com) (208.30.140.160) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Nov 2006 11:46:58 -0800 Received: from qxvcexch01.ad.quovadx.com (qxvcexch01.ad.quovadx.com [192.168.170.59]) by moroha.quovadx.com (8.13.6/8.13.6) with ESMTP id kAUJkYt9028888 for ; Thu, 30 Nov 2006 19:46:35 GMT Received: from [10.70.3.113] ([10.70.3.113]) by qxvcexch01.ad.quovadx.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 30 Nov 2006 12:46:58 -0700 Message-ID: <456F351E.6080101@roguewave.com> Date: Thu, 30 Nov 2006 12:46:38 -0700 From: Martin Sebor Organization: Rogue Wave Software User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.13) Gecko/20060417 X-Accept-Language: en-us, en MIME-Version: 1.0 To: stdcxx-dev@incubator.apache.org Subject: Re: [PATCH] RE: svn commit: r472469 - in /incubator/stdcxx/trunk/tests: include/rw_process.h self/0.process.cpp src/process.cpp References: <456F11B9.2020805@kyiv.vdiweb.com> In-Reply-To: <456F11B9.2020805@kyiv.vdiweb.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 30 Nov 2006 19:46:58.0758 (UTC) FILETIME=[4C280E60:01C714B8] X-Virus-Checked: Checked by ClamAV on apache.org Farid Zaripov wrote: [...] > > sleep() can be used instead of nanosleep()? I think so. The only potential issue is that sleep() may be implemented using alarm() and calling it might reset a previously set alarm. But that's probably something we'll have to live with. > > ChangeLog: > * process.cpp: Removed unused #include > (rw_waitpid): Used sleep() instead of nanosleep() > (rw_process_kill): Corrected timeout value to 1 second Looks good. Thanks Martin > > Farid. > > > ------------------------------------------------------------------------ > > Index: process.cpp > =================================================================== > --- process.cpp (revision 480885) > +++ process.cpp (working copy) > @@ -152,10 +152,9 @@ > > # include > # include // for waitpid() > -# include // for fork(), execv(), access() > +# include // for fork(), execv(), access(), sleep() > # include // for setjmp(), longjmp() > # include // for signal() > -# include // for nanosleep() > > /**************************************************************************/ > > @@ -509,37 +508,30 @@ > if (0 < timeout && 0 == ret) { > // process still active, wait > sig_handler_t* old_handler = signal (SIGCHLD, sig_handler); > - timespec rem = { timeout, 0 }; > > + unsigned utimeout = unsigned (timeout); > + > do { > - timespec req = rem; > - if (-1 == nanosleep (&req, &rem)) { > - if (EINTR == errno) { > - // possible that the child has exited > - ret = waitpid (pid, &status, WNOHANG); > - if (-1 == ret) { > - rw_error (0, __FILE__, __LINE__, > - "waitpid (%{P}, %#p, WNOHANG) failed: " > - "errno = %{#m} (%{m})", > - pid, &status); > - } > - else if (0 == ret) { > - // child still active > - continue; > - } > - else { > - // child has exited > - RW_ASSERT (pid == ret); > - } > - } > - else { > + rw_info (0, 0, 0, "before sleep: %u", utimeout); > + utimeout = sleep (utimeout); > + rw_info (0, 0, 0, "after sleep: %u", utimeout); > + if (utimeout) { > + // possible that the child has exited > + ret = waitpid (pid, &status, WNOHANG); > + if (-1 == ret) { > rw_error (0, __FILE__, __LINE__, > - "nanosleep (&{%i, 0}, %#p) failed: " > + "waitpid (%{P}, %#p, WNOHANG) failed: " > "errno = %{#m} (%{m})", > - timeout, &rem); > - > - ret = -1; > + pid, &status); > } > + else if (0 == ret) { > + // child still active > + continue; > + } > + else { > + // child has exited > + RW_ASSERT (pid == ret); > + } > } > else { > // timeout elapsed > @@ -590,7 +582,7 @@ > rw_process_kill (rw_pid_t pid, int signo) > { > // timeout for rw_wait_pid > - const int timeout = 1000; > + const int timeout = 1; > > #if defined (_WIN32) >