Mail Archives: djgpp/2000/12/05/21:37:51
From: | vonbane AT my-deja DOT com
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | popen hanging eventually
|
Date: | Wed, 06 Dec 2000 01:20:50 GMT
|
Organization: | Deja.com - Before you buy.
|
Lines: | 63
|
Message-ID: | <90k49f$5f9$1@nnrp1.deja.com>
|
NNTP-Posting-Host: | 24.216.64.15
|
X-Article-Creation-Date: | Wed Dec 06 01:20:50 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 x70.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
|
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.
- Raw text -