gwc@root.co.uk (Geoff Clare) (01/08/91)
src@scuzzy.in-berlin.de (Heiko Blume) writes: >yes [if you have posix stuff]: > for ( i = 0 ; i < sysconf(_SC_OPEN_MAX) ; i++ ) > close( i ); This code assumes that there is always a finite limit on the number of open file descriptors per process. On systems where there is no limit the sysconf() call will return -1, and no file descriptors will be closed. Unfortunately POSIX doesn't provide any means of finding out the highest open fd number, so there is no really robust way of handling this situation. The best I can come up with is to close all descriptors up to some arbitrary high number (e.g. 256). -- Geoff Clare <gwc@root.co.uk> (Dumb American mailers: ...!uunet!root.co.uk!gwc) UniSoft Limited, London, England. Tel: +44 71 729 3773 Fax: +44 71 729 3273
src@scuzzy.in-berlin.de (Heiko Blume) (01/10/91)
gwc@root.co.uk (Geoff Clare) writes: >This code assumes that there is always a finite limit on the number of >open file descriptors per process. On systems where there is no limit the >sysconf() call will return -1, and no file descriptors will be closed. very interesting! i still try to get my hands on the POSIX standard, until now i couldn't get it anywhere, including my universities CS library (what a shame :-(). can someone tell me just where i can get it from (i'm in germany, sigh...) >Unfortunately POSIX doesn't provide any means of finding out the highest >open fd number, so there is no really robust way of handling this situation. >The best I can come up with is to close all descriptors up to some arbitrary >high number (e.g. 256). jesus... -- Heiko Blume <-+-> src@scuzzy.in-berlin.de <-+-> (+49 30) 691 88 93 public source archive [HST V.42bis]: scuzzy Any ACU,f 38400 6919520 gin:--gin: nuucp sword: nuucp uucp scuzzy!/src/README /your/home