Ubuntu 9.1: sha...@shamer-vbox:~$ ulimit unlimited sha...@shamer-vbox:~$ ulimit -n 1024 sha...@shamer-vbox:~$ lsof -u shamer | wc 6105 54930 605988 sha...@shamer-vbox:~$ ./openLots.pl blah blah ~snip~ Could not open 1023: Too many open files at ./openLots.pl line 8.
Gentoo: sha...@hp ~ $ ulimit unlimited sha...@hp ~ $ ulimit -n 1024 sha...@hp ~ $ lsof -u shamer | wc 2320 20899 228824 sha...@hp ~ $ ./openLots.pl Could not open 1025: Too many open files at ./openLots.pl line 8. On Mon, Apr 26, 2010 at 09:13, Daniel Eggleston <[email protected]> wrote: > On Sun, Apr 25, 2010 at 05:02:05PM -0700, wenlong wrote: > > Hi All, > > > > Today, I'm playing with the "ulimit " command. My login has a ulimit > > of 1024 for open file descriptor: > > > > $ ulimit -n > > 1204 > > > > But when using lsof to list down all files (files, socket, etc) opened > > by my login, I got: > > > > $ lsof -u user | wc -l > > 3977 > > > > Can someone tell me why can my login open more files than granted by > > ulimit? I'm running: > > > > Debian stable (lenny) > > Gnome desktop environment + compiz > > > > Thanks. > > > > -- wenlong (boon leong) > > > > -- > > You received this message because you are subscribed to the Linux Users > Group. > > To post a message, send email to [email protected] > > To unsubscribe, send email to > [email protected] > > For more options, visit our group at > http://groups.google.com/group/linuxusersgroup > > > The ulimit -n is a per-process limitation (i.e. any process cannot have > more > than 1024 files open). Here is a brief example, showing a process that can > open 1024 files, but not 1025 (bearing in mind that there are already 3 > files > open: stdin, stdout, and stderr): > > egg...@pokeserver ~ $ ulimit -n > 1024 > egg...@pokeserver ~ $ lsof | grep eggled | wc -l > 4863 > egg...@pokeserver ~ $ cat openLots.pl > #!/usr/bin/perl > > ## There are already 3 file descriptors > ## Plus an offset to make the index equal to the file count. > my @fileList = (-1,0,1,2); > for (;;) { > push(@fileList,">/tmp/lotsaFilesTemp.$#fileList"); > open($fileList[$#fileList],$fileList[$#fileList]) or (print "\n\n" > and die "\n\nCould not open $#fileList: $!"); > print "$#fileList "; > } > egg...@pokeserver ~ $ ./openLots.pl > 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 > 31 > ---- snip ---- > 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 > 1021 > 1022 1023 1024 > > > > Could not open 1025: Too many open files at ./openLots.pl line 8. > egg...@pokeserver ~ $ > > > The 1025th file failed to open, with the error message "Too many files > open". > -- You received this message because you are subscribed to the Linux Users Group. To post a message, send email to [email protected] To unsubscribe, send email to [email protected] For more options, visit our group at http://groups.google.com/group/linuxusersgroup
