Sponsored Content
Full Discussion: File descriptor constant
Top Forums Programming File descriptor constant Post 71807 by vino on Monday 16th of May 2005 05:20:19 AM
Old 05-16-2005
Using getrlimit and the appropriate constants, this is what I am using now.

Code:
struct rlimit RL;

getrlimit(RLIMIT_NOFILE, &RL)
  for ( int fd = 3; fd <= RL.rlim_cur; ++fd )
   close(fd);

Apparently rlim_cur and rlim_max gives me 1024 on my machine.

Thanks,
Vino
 

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

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

5. Shell Programming and Scripting

Reading from one file and updating other file with constant entries

Hi All, Thaks for the help in my last thread. I have one more question. I have two files with ldap entries in it. One file contains all the user LDAP parameter entries (26 MB) and other file contains only the user id's that have to be inactivated. Unix script has to read from the file that has... (8 Replies)
Discussion started by: Samingla
8 Replies

6. Shell Programming and Scripting

file descriptor KSH

Hello, How can i use file descriptor in a script to read 2 files at the same time and extract line 200 from file 1 and line 500 from file 2. Thanks. (6 Replies)
Discussion started by: LiorAmitai
6 Replies

7. Programming

[Makefile]File + constant problem

Hi guys, I am writing a Makefile with some strange features. What I have is: list of files *.efi list of guids (guid is just a number) one *.efi file is supposed to be used with one guid, so efi file and guid is a pair. What I need is: list of files *.fv How to make *.fv file... (1 Reply)
Discussion started by: Chrisdot
1 Replies
getdtablesize(3C)					   Standard C Library Functions 					 getdtablesize(3C)

NAME
getdtablesize - get the file descriptor table size SYNOPSIS
#include <unistd.h> int getdtablesize(void); DESCRIPTION
The getdtablesize() function is equivalent to getrlimit(2) with the RLIMIT_NOFILE option. RETURN VALUES
The getdtablesize() function returns the current soft limit as if obtained from a call to getrlimit() with the RLIMIT_NOFILE option. ERRORS
No errors are defined. USAGE
There is no direct relationship between the value returned by getdtablesize() and OPEN_MAX defined in <limits.h>. Each process has a file descriptor table which is guaranteed to have at least 20 slots. The entries in the descriptor table are numbered with small integers starting at 0. The getdtablesize() function returns the current maximum size of this table by calling the getrlimit() function. SEE ALSO
close(2), getrlimit(2), open(2), setrlimit(2), select(3C) SunOS 5.10 1 Mar 1996 getdtablesize(3C)
All times are GMT -4. The time now is 12:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy