Message-ID: <33FBC624.3FA@post.comstar.ru> Date: Thu, 21 Aug 1997 08:37:56 +0400 From: Dim Zegebart Reply-To: zager AT post DOT comstar DOT ru Organization: Comstar Ltd. MIME-Version: 1.0 To: DJGPP Mail List Subject: Stable crash of my programm. Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk Hi, Some weeks ago I posted the similar question to our list ... No response :( So, the problem occured again and I can define more details of it ... I have writted comm monitor for logging the activity of system X, every hour it creates 10-minutes-long file and save it to local HDD and also trys to save it over the LAN onto net server (I'm using ms client for dos (full redirector with NetBEUI (Hm, why NetBEUI may be TCP/IP more prefered?))) The code is very simple and clear (I hope so :) here it is ( see exclamations in comments) - int make_remote_copy_of_file(char *from_file,char *to_file) { FILE *file_to,*file_from; char d[255],p[255]; long l; char *buf; fnsplit(to_file,d,p,NULL,NULL); strcat(d,p); // printf("%s -> %s\n",from_file,to_file); _fixpath(d,p); // printf("MKDIR : %s\n",p); if (access(p,D_OK)!=0) //directory not exists !!!!!!!!!!! Note, if network connection is lost or server shutdowned this string // !!!!!!!!!!! coused a GPF { if (mkdirs(p)) { system_msg_put(SYS_ERR_MKDIR,(int)strdup(p),errno); return(0); } } // printf("Dir Ok\n"); if ((file_to=fopen(to_file,"wb"))==NULL) { system_msg_put(SYS_ERR_FOPEN,(int)strdup(to_file),errno); return(0); } if ((file_from=fopen(from_file,"rb"))==NULL) { fclose(file_to); system_msg_put(SYS_ERR_FOPEN,(int)strdup(from_file),errno); return(0); } l=filelength(fileno(file_from)); if ((buf=(char*)alloca(l))==NULL) return(0); if ((l=fread(buf,1,l,file_from))==-1) { fclose(file_from); fclose(file_to); system_msg_put(SYS_ERR_FREAD,(int)strdup(from_file),errno); return(0); } fclose(file_from); // printf("Reading : %d\n",l); if (fwrite(buf,1,l,file_to)==-1) { fclose(file_to); system_msg_put(SYS_ERR_FWRITE,(int)strdup(to_file),errno); return(0); } fclose(file_to); // printf("Writing Ok\n"); return(1); } The question is obvious, - How to avoid such situation ? May be use TCP/IP and do ping prior to saving ? Thank you for reading my code :) -- Regards, Dim Zegebart, Moscow Russia. Ghostly basement : http://www.geocities.com/siliconvalley/pines/7817 DZCOMM - comm library for Allegro