Sponsored Content
Operating Systems AIX AIX6.1 Remove file descriptor from specified process Post 302635557 by bakunin on Saturday 5th of May 2012 10:58:03 AM
Old 05-05-2012
It is an ABSOLUTE NO-NO, ok, let me emphasize this: ABSOLUTE NO-NO to remove files which are still opened by a process. The reasons for this you have just experienced.

If you want to remove a large log file then "zap" it instead of removing it: copy /dev/null, which contains a single EOF char, to the file, overwriting its content. This way the file itself is preserved while its content is reduced to 0.

A "file" is a collection of data identified by some information in the file system and its driver: the i-node(-number), the directory location, the name, etc.. All this information is preserved by "zapping" it, while deleting it removes this data, along with the content.

Code:
 cat /dev/null > /some/large/file

I hope this helps.

bakunin
 

10 More Discussions You Might Find Interesting

1. 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

2. UNIX for Dummies Questions & Answers

File Descriptor Help

What is a file descriptor in Unix?? How to find a file descriptor of a file in Unix?? Does it have anything to do with the Inode numbers?? (3 Replies)
Discussion started by: rahulrathod
3 Replies

3. Programming

Problems with file descriptor

Hi, look at the following code: The client after estabilishing a connection with the server does the following: if ((peter = fopen(argv, "r")) == NULL){ printf("errore\n"); exit(0); } ... (11 Replies)
Discussion started by: teo
11 Replies

4. Programming

File descriptor constant

I have a requirement to close all the file descriptors from 3 to 1024 for a particular application. Right now, this is how I do it .. for ( int i = 3 ; i <= 1024; ++i ) close(i); The change I am looking at is, I want to do away with the number 1024 and replace it with a constant which... (4 Replies)
Discussion started by: vino
4 Replies

5. Shell Programming and Scripting

File Descriptor

Hello All, Im opening a file desciptor in perl and sending data using print CMD "$xyz". is there a limit to the length of the string that I can give to this CMD at a time. (3 Replies)
Discussion started by: rimser9
3 Replies

6. UNIX for Dummies Questions & Answers

File Descriptor

Hi What the below path contains? /proc/<pid>/fd (1 Reply)
Discussion started by: siba.s.nayak
1 Replies

7. AIX

Unable to gunzip .tgz file in AIX6.1

Hi guys, This is my 1st post here. I tried to Google around but failed to get my solution. So I hope you guys could help me. (I have just a basic unix background for 2years so I'm sorry if im asking stupid questions) OS - Aix 6.1, 64 bits. Server - currently I only have telnet access to a... (12 Replies)
Discussion started by: pilotHans
12 Replies

8. UNIX for Advanced & Expert Users

Close file descriptor without terminating process

Can any help me in finding the way to close opened file descriptor in Solaris ,without killing process. As accidently a file was removed which was opened by a process. Much thanks in advance :) (11 Replies)
Discussion started by: nitj
11 Replies

9. UNIX for Advanced & Expert Users

Dup2 - for file descriptor opened by a different process

is it possible to duplicate file descriptors(opened by a different process) with the help of dup or dup2. the two process do not share parent child relationship as well. (2 Replies)
Discussion started by: replytoshishir
2 Replies

10. Solaris

Bad exchange descriptor : not able to remove files under zpool

Hi , One of my zone went down and when i booted it up i could see the pool in degraded state with some check sum errors . we have brought the pool online after scrubbing. But few files are showing this error Bad exchange descriptor Please let me know how to remove these files (2 Replies)
Discussion started by: chidori
2 Replies
sem_close(2)							System Calls Manual						      sem_close(2)

NAME
sem_close - close a named POSIX semaphore SYNOPSIS
DESCRIPTION
is used to close a named semaphore. A successful call to will do the following: Remove the process's descriptor for the semaphore refer- enced by the specified structure sem. Remove the semaphore referenced by the specified structure sem, if the semaphore is marked for removal by a call to and there are no other descriptors referencing this semaphore. When the process's descriptor for the semaphore referenced by sem is removed, subsequent use of this semaphore by this process will fail. Descriptors for named semaphores are also removed by processes on exit. Calling does not affect other processes referencing the same sema- phore. To use this function, link in the realtime library by specifying on the compiler or linker command line. EXAMPLES
The following call to will close a named semaphore referred to by sem by removing the process's descriptor to the semaphore and removing the semaphore if it is marked for removal by a previous and there are no descriptors referencing it. RETURN VALUE
If the semaphore was closed and the descriptors referencing it were removed, returns 0 to the caller. If the semaphore could not be closed, the call returns -1 and sets to indicate the error. ERRORS
fails and does not perform the requested operation if the following condition is encountered: [EINVAL] The argument sem is not a valid named semaphore. WARNINGS
A single call will make the semaphore unusable by the process no matter how many times that process had called for the same semaphore. Subsequent calls to by the same process for the same semaphore will result in an undefined behavior. SEE ALSO
sem_init(2), sem_open(2), sem_unlink(2), <semaphore.h>. STANDARDS CONFORMANCE
sem_close(2)
All times are GMT -4. The time now is 04:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy