This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

strange problem with popen !!




I have the following program that run an executable (via popen) and
read the stdout of this program.

The problem is that it does not work when linked with MINGW32
configured to use MSVCRT40.DLL. But it does work when linked
with MSVCRT20.DLL. BTW it works too with VC !!!!

Does somebody what could be the problem ?

Pascal.

---------- cut here ---------- file : tryit.c
#include <stdio.h>

#define SIZEBUF 1000

int
main (void)
{
  FILE *FD;

  char buffer [SIZEBUF];
  char *buf;

  printf ("runme...\n");
  FD = popen ("runme paramx", "r");

  if (FD == NULL)
    printf ("error: FD=NULL\n");
  else
    printf ("FD=%d\n", (int)FD);

  printf ("get...\n");
  buf = fgets (buffer, SIZEBUF, FD);
  if (buf == NULL)
    perror ("error fgets");

  printf ("<1>%s\n", buf);
}
---------- cut here ---------- 



---------- cut here ---------- file : runme.c
#include <stdio.h>

int
main (int argc, char *argv[])
{
  fprintf (stderr, "output to stderr\n");
  if (argc > 1)
    printf ("line 1 - to be read (%s)\n", argv[1]);
  else
    printf ("line 1 - to be read\n");
  fprintf (stderr, "output to stderr\n");
  printf ("line 2 - to be read\n");
  fprintf (stderr, "output to stderr\n");
  exit (0);
}
---------- cut here ---------- 

---------- cut here ---------- the output
output to stderr
output to stderr
output to stderr
error fgets: No error
runme...
FD=2013522008
get...
<1>(null)
---------- cut here ---------- 




--|------------------------------------------------------------
--| Pascal Obry                               Team-Ada Member |
--|                                                           |
--| EDF-DER-IPN-SID- G A L A X I E                            |
--|                       Intranet: http://cln49ae            |
--| Bureau N-023            e-mail: pascal.obry@der.edfgdf.fr |
--| 1 Av Général de Gaulle  voice : +33-1-47.65.50.91         |
--| 92141 Clamart CEDEX     fax   : +33-1-47.65.50.07         |
--| FRANCE                                                    |
--|------------------------------------------------------------
--|
--|   http://ourworld.compuserve.com/homepages/pascal_obry
--|
--|   "The best way to travel is by means of imagination"
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]