![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How do I prevent cron from returning errors on a file not found? | goodmis | Shell Programming and Scripting | 6 | 02-06-2007 10:14 AM |
| Locking a file when using VI to prevent multiple-edit sessions by diff users | Browser_ice | AIX | 14 | 11-23-2006 10:43 AM |
| Prevent file from being mailed multiple times from a job | Sree_2503 | Shell Programming and Scripting | 2 | 11-14-2006 12:47 PM |
| Error closing read file | ALTRUNVRSOFLN | High Level Programming | 1 | 09-18-2006 12:29 PM |
| prevent file size is too large | ust | UNIX for Dummies Questions & Answers | 2 | 03-10-2005 02:04 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How to prevent an application from closing a file
I'm writing some software tests, & one of my test cases is to prevent an address space from closing a data file (file is closed & a new one opened every 15 minutes).
I can't remove or rename the file while it's being written to, any other ideas to prevent a file from being closed - or at least fake a return code from the system call so that the application thinks the close failed? |
|
||||
|
Do you have the source to the application?
Is this a reasonable test case given that the application does not do this normally? What would you expect an application to do if it got an error from "close()"? I, for one as a programmer, wouldn't assume the file was still open and continue to use the same filedescriptor. If I got an error from a close(), I would may report the error but have to treat the file descriptor as "undefined". |
|
||||
|
Quote:
The application is supposed to post an alert in the event that it is unable to close the file when the timer pops. This is the case I am supposed to test. Failure to transfer the file is a separate test case. |
|
||||
|
I suggest you change the close code to... Code:
#ifdef TEST_CLOSE_FAILED
rc=-1;
errno=EIO;
#else
rc=close(fd);
#endif
However, an alternative would be to put this file on it's own partition then force a dismount of that partition, effectively simulating the loss of access to the storage media. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|