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:in-reply-to:date:message-id; q=dns; s=default; b=dp32U38y1xwqVLY0gEibDlWdTIAsGL5rCxv1z2ZjPnm xhkKJySQM+g9xxSA6o1Nta47y/lg8ImUq25paU2EJl3uBGJe/8ekxNYQYg+DrcwC ILwY+94zG1lxWQ7Z722XI1XTQh1IIO60FZCdcMsixj+YzYZPpJPeWN5VKS3walVE = 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:in-reply-to:date:message-id; s=default; bh=BQ95QcR4iPpXLo/qqCR4T63s2GU=; b=FKkGCiQor0QMOCc14 KyyickEbKFBh30e0si0uX8+CpGcVuFzAprZahc8BUXLOXo6DnulSp/fvbw/bFN5o 2+o6+zoWsiMmrSkCXXjpw8DNtqL6+Bfsgub4WNH3Rdjj2XO5lNHkOi1/gHgqbpTs p2yNquIXPvr0QOmWo3khf/Hhyc= 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.3 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-HELO: na3sys009aog126.obsmtp.com To: cygwin AT cygwin DOT com From: David Levine Subject: Re: nested popen()'s lead to fgets() failure on 64-bit only In-Reply-To: Your message of Mon, 13 Jan 2014 13:09:33 +0100 Date: Mon, 13 Jan 2014 09:35:35 -0500 Message-ID: <25675-1389623735.405019@VSdY.Cv9S.eTM_> Corinna wrote: > That's the version number of the setup-x86_64.exe tool, not the version > number of Cygwin. Try `uname -r'. 1.7.27(0.271/5/3) > Maybe you're calling the wrong file command? What's your $PATH set to? > What if you change your popen call to run /usr/bin/file.exe with full > path? > > if ((f2 = popen("/usr/bin/file --mime-type /usr/bin/file.exe", "r"))) My PATH picks /usr/bin/file, but just to be sure I hard coded it, and also used it for the first popen(), and also set PATH to /usr/bin: $ gcc -o nested_popen nested_popen.c -Wall -Wextra && \ PATH=/usr/bin ./nested_popen buf1 = /usr/bin/file.exe: application/x-dosexec popen: No error fgets2 EOF It shouldn't be at EOF in this case. If I change the second popen() to open anything, e.g., popen("garbage,really", "r"), it still reports success. We're getting closer? David #include int main() { FILE *f1, *f2; if ((f1 = popen("file --mime-type /usr/bin/file.exe", "r"))) { char buf1[BUFSIZ]; while (fgets(buf1, sizeof buf1, f1)) { printf(" buf1 = %s", buf1); if ((f2 = popen("/usr/bin/file.exe --mime-type /usr/bin/file.exe", "r"))) { char buf2[BUFSIZ]; perror("popen"); /* This fgets call fails on 64-bit Cygwin 1,7.27(0.271/5/3), with "No error". */ if (fgets(buf2, sizeof buf2, f2)) { printf(" buf2 = %s", buf2); } else if (feof (f2)) { fputs ("fgets2 EOF\n", stderr); } 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