The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Operating Systems > AIX
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-06-2008
jasahl jasahl is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 3
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?
  #2 (permalink)  
Old 01-06-2008
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
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".
  #3 (permalink)  
Old 01-06-2008
jasahl jasahl is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 3
Quote:
Originally Posted by porter View Post
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".
I do have access to the source code (albeit read only). This is an application that records system information to a file. The file is closed every 15 minutes and sent to Enterprise Storage. A new file is opened.

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.
  #4 (permalink)  
Old 01-06-2008
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
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.
  #5 (permalink)  
Old 01-06-2008
jasahl jasahl is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 3
Thanks - the forced dismount is likely the best option since we are not permitted to modify code for formal testing.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:27 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0