www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/12/05/23:21:36

From: vonbane AT my-deja DOT com
Newsgroups: comp.os.msdos.djgpp
Subject: Re: popen hanging eventually
Date: Wed, 06 Dec 2000 04:14:52 GMT
Organization: Deja.com - Before you buy.
Lines: 77
Message-ID: <90kefp$d7a$1@nnrp1.deja.com>
References: <90k49f$5f9$1 AT nnrp1 DOT deja DOT com>
NNTP-Posting-Host: 24.216.64.15
X-Article-Creation-Date: Wed Dec 06 04:14:52 2000 GMT
X-Http-User-Agent: Mozilla/5.0 (X11; U; Linux 2.2.17 i686; en-US; m18) Gecko/20001107 Netscape6/6.0
X-Http-Proxy: 1.0 x60.deja.com:80 (Squid/1.1.22) for client 24.216.64.15
X-MyDeja-Info: XMYDJUIDvonbane
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Some more information after i played with this all night.

in dos mode it works fine, its only when running it from a dos window in
windows when the problem occurs.  its usually been around 12-13 loops
before it fails to read anything from the pfp file pointer.

there must be some setting in windows i need to change to make this
work?  or is this doomed to not work in windows?

In article <90k49f$5f9$1 AT nnrp1 DOT deja DOT com>,
  vonbane AT my-deja DOT com wrote:
> i have a program running on windows 95/98.  it popens a rsh program to
> rsh to a unix box and dd several files back to my program.  eventually
> the popen of the rsh command fails to read any data.  i stripped my
> program down to this basic part and will include that at the end, it
> also is only dd'ing the same file to my program but it hangs up non the
> less.  I thought it was a max file open problem but popen doesn't return
> NULL.  after so many loops it simply reads 0 bytes and returns back out.
>  why is this.  i can get it to work on a windows nt machine
>
> #include <conio.h>
> #include <dir.h>
> #include <errno.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include <unistd.h>
> #include <sys/stat.h>
>
> #define FILE_BUFFER 512
>
> int main( ) {
>   FILE *fp;
>   FILE *pfp;
>   int i = 0;
>   char buffer[FILE_BUFFER];
>   int read;
>   char command[512];
>
>   while ( (pfp = popen("rsh c-class1 -l starsys \"dd
> if=/etc/hosts\"","rb")) != NULL ) {
>     sprintf(command,"c:\\testout%d.txt",i);
>     fp = fopen(command,"wb");
>
>     while ( !feof(pfp) ) {
>       if ( (read = fread(buffer,sizeof(char),FILE_BUFFER,pfp)) !=
> FILE_BUFFER ) {
>         if ( !feof(pfp) || ! read ) {
>           printf("error reading, read %d bytes\n",read);
>           return 1;
>         }
>       }
>
>       if ( fwrite(buffer,sizeof(char),read,fp) != read ) {
>         printf("error writing\n");
>         return 1;
>       }
>     }
>     fclose(fp);
>
>     printf("%d\n",i);
>     pclose(pfp);
>     i++;
>   }
>
>   printf("opened %d files\n",i);
>
>   return 0;
> }
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


Sent via Deja.com http://www.deja.com/
Before you buy.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019