X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Date: Sat, 16 Jul 2011 09:24:51 +0200 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: popen () fails when running from the windows prompt Message-ID: <20110716072451.GO2125@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <4E2089CB DOT 4090608 AT valdetaro DOT com> <4E20BFBC DOT 7050504 AT towo DOT net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <4E20BFBC.7050504@towo.net> User-Agent: Mutt/1.5.21 (2010-09-15) Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: 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 On Jul 16 00:31, Thomas Wolff wrote: > Am 15.07.2011 21:22, schrieb Andy Koppe: > >On 15 July 2011 19:41, Luiz Claudio Valdetaro wrote: > >>i, > >> > >>I am planning a minimalistic installation of my application using cygwin. > >>Everything works fine, except that popen() fails when running from the > >>windows prompt. > >> > >>If I ran from the bash shell prompt of cygwin , it works fine. It is the > >>only api I use that is failing. I created a simple, test program to narrow > >>the issue, and it also fails. > >> > >>my intention is an installation with just my app, plus the cygwin.dll, as > >>little files as possible. > >> > >>This is my test program: > >> > >>main (argc,argv) > >>int argc; > >>unsigned char *argv[]; > >>{ > >>FILE *f; > >>char command[80]="ls -l CGI-BIN"; > >>char response[200]; > >> f = popen (command,"r"); > >> if (f == NULL) { > >> puts ("stream error"); > >> exit (0); > >> } > >> while (fgets(response,199,f) != NULL) { > >> puts (response); > >> } > >> fclose (f); > >>} > >> > >>The program allays fails printing "stream error" > >It's because popen() requires /bin/sh. > It works if you copy the following files plus popen itself into a > subdirectory "bin" and include that into your PATH: > cyggcc_s-1.dll > cygiconv-2.dll > cygintl-8.dll > cygncursesw-10.dll > cygreadline7.dll > cygwin1.dll > ls.exe > sh.exe > > I wonder though why all these libraries are dependencies; the > program doesn't use curses, nor intl or iconv, and I linked it with > -static-libgcc. Still miraculous. Not really. These are dependencies of sh.exe, which is bash by default. $ ldd popen | grep -i cyg cygwin1.dll => /usr/bin/cygwin1.dll (0x61000000) cyggcc_s-1.dll => /usr/bin/cyggcc_s-1.dll (0x6d5d0000) $ ldd /bin/ls | grep -i cyg cygwin1.dll => /usr/bin/cygwin1.dll (0x61000000) cygintl-8.dll => /usr/bin/cygintl-8.dll (0x6a990000) cygiconv-2.dll => /usr/bin/cygiconv-2.dll (0x6b770000) cyggcc_s-1.dll => /usr/bin/cyggcc_s-1.dll (0x6d5d0000) $ ldd /bin/sh | grep -i cyg cygwin1.dll => /usr/bin/cygwin1.dll (0x61000000) cygintl-8.dll => /usr/bin/cygintl-8.dll (0x6a990000) cygiconv-2.dll => /usr/bin/cygiconv-2.dll (0x6b770000) cyggcc_s-1.dll => /usr/bin/cyggcc_s-1.dll (0x6d5d0000) cygreadline7.dll => /usr/bin/cygreadline7.dll (0x725a0000) cygncursesw-10.dll => /usr/bin/cygncursesw-10.dll (0x6a2e0000) Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Project Co-Leader cygwin AT cygwin DOT com Red Hat -- 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