X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:from:subject:date:message-id; q=dns; s= default; b=ucTwvUUuBe84dgrTKexJBfW8wXdSCKG2YE+PhEdzqWY5WGlHhbI4o oDXbPB0o6/IRSn4kFFpLniZsUNxr19WEgDBosrSSkpXOSmg4+bhgUY7bwK6byTnV +3ncqySD1Fb2mGnC6D4ZK5hVDzKcCS1jtfxT7hT79PPlfRzbYZon1s= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:from:subject:date:message-id; s=default; bh=qm+RdSod5xofTeaRO5Ohs4czx2o=; b=rTwzzZXde4i8fbo61sC5i/BTGlrl aHL82MYvtCFvKhqCPSbrcwgtuuuvbk2v0DSWGxrHp+9R/+szqOJO6mZIzGNrgRUW 1UpQAySIkd/GFpW9SJf2rkPINXu9qUudtzzput4xE0oTnp7b2T4gpZDCJ0t59gKP DHnQtlubTv1VmlI= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-HELO: na3sys009aog107.obsmtp.com To: cygwin AT cygwin DOT com From: David Levine Subject: nested popen()'s lead to fgets() failure on 64-bit only Date: Sun, 12 Jan 2014 21:15:59 -0500 Message-ID: <18833-1389579359.738859@Poig.bVYt.cj35> Hi, The program below works just fine on 32-bit Cygwin: buf1 = /usr/bin/file.exe buf2 = /usr/bin/file.exe: application/x-dosexec But on 64-bit Cygwin (2.831), the second fgets() fails: buf1 = /usr/bin/file.exe fgets2: No error It only seems to happen with nested popen()'s. Is it due to a problem in the Cygwin lib? Thanks, David #include int main() { FILE *f1, *f2; if ((f1 = popen("ls /usr/bin/file.exe", "r"))) { char buf1[BUFSIZ]; while (fgets(buf1, sizeof buf1, f1)) { printf(" buf1 = %s", buf1); if ((f2 = popen("file --mime-type /usr/bin/file.exe", "r"))) { char buf2[BUFSIZ]; /* This fgets call fails on 64-bit Cygwin, with "No error". */ if (fgets(buf2, sizeof buf2, f2)) { printf(" buf2 = %s", buf2); } else { perror("fgets2"); } pclose(f2); } else { perror("popen2"); } } pclose(f1); } else { perror("popen1"); } return 0; } -- 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