| delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| X-Spam-Check-By: | sourceware.org |
| Date: | Thu, 13 Aug 2009 16:15:20 -0400 |
| From: | Christopher Faylor <cgf-use-the-mailinglist-please AT cygwin DOT com> |
| To: | cygwin AT cygwin DOT com |
| Subject: | Re: Cygwin1.dll 1.7.0-5x: RSYNC failures in close() system call on pipe file descriptors |
| Message-ID: | <20090813201520.GA4365@ednor.casa.cgf.cx> |
| Reply-To: | cygwin AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| References: | <4A844A97 DOT 1050809 AT sipxx DOT com> <loom DOT 20090813T193850-591 AT post DOT gmane DOT org> |
| MIME-Version: | 1.0 |
| In-Reply-To: | <loom.20090813T193850-591@post.gmane.org> |
| User-Agent: | Mutt/1.5.20 (2009-06-14) |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Id: | <cygwin.cygwin.com> |
| List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com> |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sourceware.org/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT com |
On Thu, Aug 13, 2009 at 07:52:01PM +0000, Eric Blake wrote:
>cygwin <karl <at> sipxx.com> writes:
>
>>
>> - if (dup2(to_child_pipe[0], STDIN_FILENO) < 0 ||
>> - close(to_child_pipe[1]) < 0 ||
>> - close(from_child_pipe[0]) < 0 ||
>> - dup2(from_child_pipe[1], STDOUT_FILENO) < 0) {
>> - rsyserr(FERROR, errno, "Failed to dup/close");
>> + if (dup2(to_child_pipe[0], STDIN_FILENO) < 0) {
>> + rsyserr(FERROR, errno, "Failed to dup2(to-0)");
>> exit_cleanup(RERR_IPC);
>> }
>> - if (to_child_pipe[0] != STDIN_FILENO)
>> - close(to_child_pipe[0]);
>> - if (from_child_pipe[1] != STDOUT_FILENO)
>> - close(from_child_pipe[1]);
>
>Ouch. rsync has a bug even without your patch: if you run rsync with
>stdout closed (as opposed to redirected), then to_child_pipe[0] can be
>1, and you end up closing the just-duplicated from_child_pipe[1] that
>was copied to the new stdout. To be correct, rsync must compare
>to_child_pipe[0] against both 0 and 1, not just 0 (likewise for
>from_child_pipe[1] against both 0 and 1, not just 1). Amazing how
>often this type of bug reappears, too - historical cygwin has had it in
>the past with newlib's popen implementation (I fixed it 2006-08-22), as
>well as m4 1.4.13-1 having it due to code from gnulib (I fixed it
>2009-07- 17).
Just a point of order: Cygwin doesn't use the newlib version of
popen.
cgf
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |