The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Creating an Ajax Process Using PHP and Oracle iBot Oracle Updates (RSS) 0 04-06-2008 06:10 AM
creating 10 process kpkant123 Shell Programming and Scripting 2 05-21-2007 06:28 PM
how can i check if text file is closed ? umen Shell Programming and Scripting 13 01-12-2007 11:40 AM
creating child process Confuse High Level Programming 12 05-27-2005 12:48 PM
file activity (open/closed) file descriptor info using KORN shell scripting Gary Dunn UNIX for Dummies Questions & Answers 3 06-07-2004 02:54 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-18-2003
linkjack linkjack is offline
Registered User
  
 

Join Date: Jun 2001
Location: Shanghai,China
Posts: 3
How to know a new file is in process of creating? It has not been closed.

I am programming some data loader of oracle with unix c, when I find new data file, then read it to database and delete it. but one issue, if the file is in process of creating, not been closed yet. I will read zero or part of data content, this will cause problem. I want to know whether some unix system function can check this situation, avoid it.

Thanks!
  #2 (permalink)  
Old 01-18-2003
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,131
You really need some cooperation from the creating process to achieve the best solution. The creating process should open a temporary filename and write to that. Once it is done, it should rename the file to the real name. That way, when your program sees the real filename appear, it will know that it can proceed.
  #3 (permalink)  
Old 02-11-2003
mbb mbb is offline
Registered User
  
 

Join Date: Aug 2001
Location: UK
Posts: 104
Perderabo is correct some handshaking will be required.

Some OS may provide low level file locking facilities but these may not be guaranteed or portable.

Another way of indicating a file has been completed is an associated 'trigger file'. e.g. myfile and myfile.trig

The 'trigger' file will be an empty file and simply indicate the the real file is ready for processing.

The naming convention is aribrary but the method could be used if there are restrictions in unique file naming from the system for whatever reason.

Either method would be OK, it is just a matter of how you decide to implement your handshaking between processes.

MBB
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:57 AM.


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