On Tue, 2008-11-18 at 14:15 +1100, Matthew Hannigan wrote: > On Tue, Nov 18, 2008 at 08:54:47AM +1100, Peter Miller wrote: > > Ho Folks, > > > > yet another puzzle for you. > > > > fork(2) can fail and report EAGAIN if > > a. run out of a resource other than memory > > b. too many processes on the system > > c. too many processes per uid > > d. too many child processes per process > > > > for each of the above, on linux, how the heck do you > > 1. obtain current usage > > 2. obtain limit > > > > afaics getrusage(2) is no help > > > > (d)(2) can be done by getrlimit(RLIMIT_NPROC) or sysconf(_SC_CHILD_MAX) > > except that both man pages are pretty vague as to whether they are (c) > > or (d). > > > > It would be great if libexplain could distinguish between the 4 cases. > > > > suggestions?
> Linus was adamant that he was not going to have such fixed numbers in the > kernel; that these in principal could certainly change dynamically. > Per process, per hour, per user or whatever. I can see why he doesn't want fixed numbers in the kernel, but that's not what I'm after. <tangent> Posix doesn't insist of fixed numbers, tho (I've been reading it way too much, lately) so I can't quite see why he would object to the sysconf() system call supplying at-this-moment numbers. </tangent> Essentially I want to be able to say fork() failed, Resource temporarily unavailable (EAGAIN) because the process has reached its limit of child processes (42) ...because the system limit of process for this user (42, "pmiller") has been reached (666). ...because there are too many processes running in the system (42987) I'm happy for the numbers to go up and down, I'm happy to access the limits via a system call or some /proc groping (throwing another process is probably impossible in this case, but opening a new file descriptor may not be), I just want to be able to distinguish the cases, because the correct action to fix each of them differs. Trying to explain the causes of obscure <errno.h> values is like a riddle-based mystery tour of Asymmetric Api Land. "Yes, that error happened; yes, the system knows why; no, the system will not tell you your crime. Guilty! Ten years imprisonment. Next!" Regards Peter Miller <[EMAIL PROTECTED]> /\/\* http://miller.emu.id.au/pmiller/ PGP public key ID: 1024D/D0EDB64D fingerprint = AD0A C5DF C426 4F03 5D53 2BDB 18D8 A4E2 D0ED B64D See http://www.keyserver.net or any PGP keyserver for public key. "Jack Valenti is to the public domain as Jack The Ripper is to women."
signature.asc
Description: This is a digitally signed message part
_______________________________________________ coders mailing list coders@slug.org.au http://lists.slug.org.au/listinfo/coders