02-08-2008
I'm not sure about what or why you're doing things...?
This is how unlink (remove() in C or rm in shell ) works: it deletes the file from the directory, but the file's data and any currently open file descriptors can see that data.
When the last file descriptor to the file close, then the data itself goes away.
This means process #1 can keep on reading the file. When it is done with the file -- and if it was deleted by process #2, then the file's data will no longer be accessible.
If process #2 opens another file with the same file name it will not affect process #1's data.
So, why are you doing this? The only reason I know of to delete a file that is open is to hide it from all other processes. It's a good security measure.
You can achieve synchronization using a lock file - another file that tells process #1 and process #2 when they can do something with the data - if you need it.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I know I saw a couple posts about this a long time ago, but could not find them with search. Please refresh my memory.
-Chuck (1 Reply)
Discussion started by: 98_1LE
1 Replies
2. Shell Programming and Scripting
Hi,
Actually I am want to cut the three fields of "file-nr" file.
$ cat /proc/sys/fs/file-nr
638 219 52270
I want to assign these value to diffrent varibales as follow:-
a=638
b=219
c=52270
I tried to use cut command for this purpose and also tried to squeeze all sapces... (6 Replies)
Discussion started by: bisla.yogender
6 Replies
3. Shell Programming and Scripting
Guys,
My log files stored in the date format format below(log_20080714072942):
TIMESTAMP=`date +%Y%m%d%H%M%S`
LOG=/log/log_${TIMESTAMP}.log
I'm looking for a shell script which deletes all files which is older than 3 months from today.
Regards,
Bhagat (3 Replies)
Discussion started by: bhagat.singh-j
3 Replies
4. Solaris
I know how to check if any file has a unix process using a file by looking at 'lsof <fullpath/filename>' command.
I think using lsof is very expensive. Also to make it accurate we need to inlcude fullpath of the file.
Is there another command that can tell if a file has a truely active... (12 Replies)
Discussion started by: kchinnam
12 Replies
5. Shell Programming and Scripting
I'm trying to write a script that will do an ls of a location, echo it into a file, and then read that file and selectively delete files/folders, so it would go something like this:
cd $CLEAN_LOCN
ls >>$TMP_FILE
while read LINE
do
if LINE = $DONTDELETE
skip
elseif LINE =... (2 Replies)
Discussion started by: MaureenT
2 Replies
6. Shell Programming and Scripting
Hi....
I have a need of script to do delete row whenever condition is true....
2.16 (3) 1 3 9999 0 (1) (0)
34.42 (4) 1 3 9999 37 (2) (3)
34.38 (4) 1 3 9999 64 (2) (3)
34.4 (4) 1 3 1 ... (13 Replies)
Discussion started by: nex_asp
13 Replies
7. Shell Programming and Scripting
Hi Guru's
The script has to read an entry from one file and delete the set of lines form other file. Below is the format of the file. In the below example, script should read the entries from input file 2 and delete the entries from input file 1.
Input file 1
cn: test@test1.com
abc:... (7 Replies)
Discussion started by: Samingla
7 Replies
8. UNIX for Dummies Questions & Answers
I have file called "text". The contents are as below :
aaa
bbb
ccc
ddd
eee
ffff
ddd
hhhh
iiii
I want to read this file without opening and and delete the last line. How can it be done? (4 Replies)
Discussion started by: the_hunter
4 Replies
9. UNIX for Beginners Questions & Answers
i want to give users the ability to create write and read files in other user directory , but not to have option to delete the file after created ( sticky bit not going to work here ... ) for example :
i have user : manager with directory repository
i have user : worker1 that need to write... (4 Replies)
Discussion started by: umen
4 Replies
10. Shell Programming and Scripting
I have a CSV file with hdfs directories, hive tables and hbase tables.
1. first column - hdfs directories
2. second column - hive tables
3. third column - hbase tables
I have to check the csv file and look for the first column and delete the hdfs directory from the hdfs path, now... (2 Replies)
Discussion started by: shivamayam
2 Replies
LEARN ABOUT REDHAT
getpassphrase
getpass(3C) Standard C Library Functions getpass(3C)
NAME
getpass, getpassphrase - read a string of characters without echo
SYNOPSIS
#include <stdlib.h>
char *getpass(const char *prompt);
char *getpassphrase(const char *prompt);
XPG4, SUS, SUSv2
#include <unistd.h>
char *getpass(const char *prompt);
DESCRIPTION
The getpass() function opens the process's controlling terminal, writes to that device the null-terminated string prompt, disables echoing,
reads a string of characters up to the next newline character or EOF, restores the terminal state and closes the terminal.
The getpassphrase() function is identical to getpass(), except that it reads and returns a string of up to 257 characters in length.
RETURN VALUES
Upon successful completion, getpass() returns a pointer to a null-terminated string of at most 9 bytes that were read from the terminal
device. If an error is encountered, the terminal state is restored and a null pointer is returned.
ERRORS
The getpass() and getpassphrase() functions may fail if:
EINTR The function was interrupted by a signal.
EIO The process is a member of a background process attempting to read from its controlling terminal, the process is ignoring
or blocking the SIGTTIN signal or the process group is orphaned.
EMFILE OPEN_MAX file descriptors are currently open in the calling process.
ENFILE The maximum allowable number of files is currently open in the system.
ENXIO The process does not have a controlling terminal.
USAGE
The return value points to static data whose content may be overwritten by each call.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |getpass() is Standard. |
+-----------------------------+-----------------------------+
|MT-Level |Unsafe |
+-----------------------------+-----------------------------+
SEE ALSO
attributes(5), standards(5)
SunOS 5.10 2 Sep 2003 getpass(3C)