On Jan 12 21:15, David Levine wrote: > 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:
That's the version number of the setup-x86_64.exe tool, not the version number of Cygwin. Try `uname -r'. > 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? Works fine for me on Cygwin 1.7.27: $ uname -rm 1.7.27(0.271/5/3) x86_64 $ file --version file-5.13 magic file from /usr/share/misc/magic $ ./popen-test buf1 = /usr/bin/file.exe buf2 = /usr/bin/file.exe: application/x-dosexec $ The fact that fgets returns NULL doesn't mean an error occured. fgets also returns NULL at EOF, meaning no output in this case, which you should test, too: if (fgets(buf2, sizeof buf2, f2)) printf(" buf2 = %s", buf2); else if (feof (f2)) fputs ("fgets2 EOF\n", stderr); else perror("fgets2"); 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"))) Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat
pgpxGEKtuo5Cw.pgp
Description: PGP signature