![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| Help with exec command and file descriptors?? | rfourn | Shell Programming and Scripting | 1 | 07-18-2007 06:05 PM |
| File Descriptors + cron | matrixmadhan | UNIX for Advanced & Expert Users | 7 | 05-23-2007 01:53 PM |
| Sockets and File descriptors | gstlouis | High Level Programming | 3 | 12-12-2005 07:36 AM |
| file descriptors | a25khan | UNIX for Dummies Questions & Answers | 3 | 01-27-2004 07:46 PM |
| File Descriptors | shibz | UNIX for Advanced & Expert Users | 3 | 12-18-2002 10:12 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Hi,
I have written a daemon process, to perform certain operations in the background. For this I have to close, the open file descriptors, Does anybody know how to find out the number of open file descriptors ? Thanks in Advance, Sheetal |
|
|||||
|
In general when you write a daemon process you...
Become a session leader - fork() Become a process-group leader - setsid() Dissociate from controlling terminal - setsid() normally does this too. chdir to '/' - chdir() Set file creation mask to 0 - umask(0) You still need to close unneeded descriptors. Assuming you haven't opened anything, you can simply do... for (i = 0; i < 10; i++) close(i); As Perderabo says, "The close call will fail if the file is not open, so you just ignore that error." At this point, you have initalized your daemon process. A great reference book with examples of this is... Advanced Programming in the UNIX Environment by W. Richard Stevens |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|