![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| HP-UX HP-UX (Hewlett Packard UniX) is Hewlett-Packard's proprietary implementation of the Unix operating system, based on System V. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Will the output file be opened and closed several times? | koifans | Shell Programming and Scripting | 7 | 12-28-2007 06:57 AM |
| CIFS Code Opened for Windows File Sharing - Redmond Developer News | iBot | UNIX and Linux RSS News | 0 | 12-16-2007 02:20 PM |
| Command to find last time file was opened | sbr262 | UNIX for Dummies Questions & Answers | 3 | 07-18-2007 03:23 PM |
| multiple files opened in awk | krhamidou | Shell Programming and Scripting | 0 | 07-18-2006 09:54 AM |
| maximum number of times - a file can be opened | matrixmadhan | High Level Programming | 3 | 03-21-2006 11:24 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I made this in C like this:
void closeAllOpenedFiles() { //nombre maximum de fichiers que peut ouvrir un processus int nombre_max_fichiers=sysconf(_SC_OPEN_MAX); int i=0; struct stat filestat; FILE * currentFile=NULL; //Parcours des fichiers ouverts par le processus for(i=3;i<nombre_max_fichiers;++i) { //Si le fichier est ouvert if(fstat(i,&filestat)==0) { currentFile=fdopen(i,(char*)fcntl(i,F_GETFL)); if(currentFile!=NULL) { //On fait le flush fflush(currentFile); //On ferme le fichier close(i); } } } //Parcours sut stdin,stdout,stderr for(i=0;i<3;++i) { currentFile=fdopen(i,(char*)fcntl(i,F_GETFL)); //On fait le flush fflush(currentFile); } } That has solved my problem because when my program meet an error i call this routine to close all opened files. Thanks. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|