How to know a new file is in process of creating? It has not been closed.


 
Thread Tools Search this Thread
Top Forums Programming How to know a new file is in process of creating? It has not been closed.
# 1  
Old 01-18-2003
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  
Old 01-18-2003
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  
Old 02-11-2003
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Creating bash script to process a data file based on the menu

Hey, im fairly new to unix and Im trying to make this unix project that would display a menu and do the following. MENU =========================== (p, P) Print users info (a, A) Add new user (s, S) Search user (d, D) Delete user (x,X) Exit Enter your choice: Trying to... (3 Replies)
Discussion started by: ultimaxtrd
3 Replies

2. AIX

Process using/creating files in the filesystem

Hello Team, In a application filesystem, there is a process keep creating the log files. Due to that the filesystem keep getting full. Please let me know how to identify the process which is keep writing in the filesystem. fuser -u <FS> will show only the user who using the filesystem.... (3 Replies)
Discussion started by: gowthamakanthan
3 Replies

3. Shell Programming and Scripting

creating an automation process in unix .

hi i need shell script in ksh for the automation process in informtica. The automation process is like this . i have a folder in unix . when this folder gets updated (like if a file or files is/are added to the folder) an event in informatica is triggered and after the process is done in... (2 Replies)
Discussion started by: kumar8887
2 Replies

4. Shell Programming and Scripting

Creating background process for my shell

I actually posted this problem on a different forum, but figured this would be a more appropriate place to post it. OK so I've created my own shell, but I can't get the background process function to run properly! What I want to do is to run a process in the background, and also print when the... (2 Replies)
Discussion started by: hansel13
2 Replies

5. Programming

read() blocks process until the stream is closed

Hi @all, i really stuck in programming a tool with bidirectional process communication (popen(cmd, "rw") ... something like that ;-)). Here is the code: if(pipe(p_stdin) != 0 || pipe(p_stdout) != 0) { fprintf(stderr, "Aufruf von pipe() schlug fehl.\n"); exit(1); } ... (6 Replies)
Discussion started by: jens.g
6 Replies

6. Shell Programming and Scripting

Match File and Copy File Script (Homework, Closed)

Can you please help on this? I am looking for the shell script which does following:- step 1: It should open the file /u/manish/input/FileIndex.dat and read line by line step 2: Once first line is read (for ex: File1), we have to find a file, that contains this matching... (4 Replies)
Discussion started by: teteguru1
4 Replies

7. Programming

Creating 3 process and piping a message

sorry im very new to this but i am supposed to create 3 processes A,B, and C and have a direct link from a to b, b to c, and c to a. here is my code. It does work, however if you look at what I bolded as long as my final read is p it seems to always work, regardless of the bolded section. ... (6 Replies)
Discussion started by: p00ndawg
6 Replies

8. Shell Programming and Scripting

creating 10 process

can anyone tell me how to Create ten processes and display useful information about them including PID, starting-time in unix using c or c++ language. i tried to create 10 different processes using fork and exec but i couldn't display those process info:PID,STIME. my sample code ......... (2 Replies)
Discussion started by: kpkant123
2 Replies

9. Programming

creating child process

i want to create 3 child processes from the same parent using folk. I know how to use folk but my child processes did not come from the same parent. Any suggestion what i did wrong ? (12 Replies)
Discussion started by: Confuse
12 Replies

10. UNIX for Dummies Questions & Answers

file activity (open/closed) file descriptor info using KORN shell scripting

I am trying to find a way to check the current status of a file. Such as some cron job processes are dependent on the completion of others. if a file is currently being accessed / modified or simply open state I will wait until it is done being processed before attempting the next process on that... (3 Replies)
Discussion started by: Gary Dunn
3 Replies
Login or Register to Ask a Question