test fork
test fork
- Subject: test fork
- From: Brian Tabone <email@hidden>
- Date: Sun, 16 Nov 2003 23:56:28 -0600
Joey,
I have a very simple c program that you can use to test your fork
limit.
Set your max proc per uid to some number (say 200),
set your shell ulimit -u
then do a ps -U you | wc -l to see how many procs you currently have
under your username.
run ./test_fork xxx, so that you end up bumping up to or just over your
max proc limit.
The idea is to play around with the numbers to verify that your
maxprocperuid setting is taking hold. If it all works as planned, then
at least you can rule out one source of the problem.
After 20 seconds, the children processes will die off, and your account
will be usable again.
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int main(int argc, char * argv[])
{
int counter = 0;
int max = 0;
int number_forked = 0;
pid_t pid;
if (argc < 2)
{
printf ("You must specify number of children to fork\n");
exit (-1);
}
max = atoi(argv[1]);
for (counter = 0; counter < max; counter ++)
{
pid = fork();
if (pid == 0)
{
/* We are in the child, sleep away
* Don't sleep for too long, so we don't lock up
* the account for an extended period of time
*/
sleep(20);
}
else if (pid != -1)
{
number_forked++;
printf ("Child pid is %d, count is %d\n", pid, counter);
}
}
printf ("Number of successful forks is %d\n", number_forked);
}
Anyway, hope that is of some help
-Brian T
On Nov 16, 2003, at 11:14 PM, Joey Stanford wrote:
>
Hi Brian!
>
>
Here you go... Don't think it would be much help though..
>
>
[joey@futune]:/Users/joey>ulimit -a
>
core file size (blocks, -c) 0
>
data seg size (kbytes, -d) unlimited
>
file size (blocks, -f) unlimited
>
max locked memory (kbytes, -l) unlimited
>
max memory size (kbytes, -m) unlimited
>
open files (-n) 10240
>
pipe size (512 bytes, -p) 1
>
stack size (kbytes, -s) 65536
>
cpu time (seconds, -t) unlimited
>
max user processes (-u) 512
>
virtual memory (kbytes, -v) 9007199254806527
>
[joey@futune]:/Users/joey>
>
>
>
On Nov 16, 2003, at 10:06 PM, Brian Tabone wrote:
>
>
> Joey,
>
>
>
> I was re-reading your message and noticed you had already tried
>
> maxprocperuid, my bad. However, What does
>
> bash> ulimit -a
>
> Say on your machine, on mine, even though ulimit says unlimited,
>
> ulimit -a tells me
>
>
>
> ulimit -a
>
> core file size (blocks, -c) 0
>
> data seg size (kbytes, -d) 6144
>
> file size (blocks, -f) unlimited
>
> max locked memory (kbytes, -l) unlimited
>
> max memory size (kbytes, -m) unlimited
>
> open files (-n) 1024
>
> pipe size (512 bytes, -p) 1
>
> stack size (kbytes, -s) 8192
>
> cpu time (seconds, -t) unlimited
>
> max user processes (-u) 100
>
> virtual memory (kbytes, -v) 14336
>
>
>
> I think you have to explicitly bump up your ulimit in your shell
>
>
>
> -Brian T
>
> On Nov 16, 2003, at 8:32 PM, Joey Stanford wrote:
>
>
>
>> Howdy!
>
>>
>
>> I'm out of options, hoping you guys (and girls) might be able to clue
>
>> me in.
>
>>
>
>> Running 10.3 will all the latest updates on a 2ghz, 2gig Dual G5.
>
>> Using tcsh but bash has same problem.
>
>>
>
>> I keep running out of "resources" whatever that is when I hit about
>
>> 135
>
>> pids (and I have over 100gig of disk left and about 500meg of unused
>
>> memory when this happens). I get the standard "unable to fork"
>
>> errors.
>
>>
>
>> e.g.
>
>> 2003-11-14 10:56:20.479 Konfabulator[6491] Exception raised during
>
>> posting of notification. Ignored. exception: couldn't fork
>
>> 2003-11-14 16:18:14.697 Mail[1770] Exception raised during posting of
>
>> notification. Ignored. exception: couldn't fork
>
>>
>
>> In term I get just "unable to fork"
>
>>
>
>>
>
>> I bumped up my sysctl using /etc/sysctl.conf:
>
>> kern.maxproc=2048
>
>> kern.maxprocperuid=512
>
>>
>
>> and then unlimited in the shell:
>
>>
>
>> [joey@futune]:/Applications/entropy/src> limit
>
>> cputime unlimited
>
>> filesize unlimited
>
>> datasize unlimited
>
>> stacksize 65536 kbytes
>
>> coredumpsize unlimited
>
>> memoryuse unlimited
>
>> descriptors 10240
>
>> memorylocked unlimited
>
>> maxproc 512
>
>>
>
>>
>
>> [joey@futune]:/Applications/entropy/src> lsof | wc -l
>
>> 394
>
>> kern.maxfiles = 12288
>
>> kern.maxfilesperproc = 10240
>
>>
>
>> Help? Any ideas?
>
>>
>
>> Thanks!
>
>>
>
>> ----------------------
>
>> http://stan4d.net
>
>>
>
>> http://entropy.stop1984.com
>
>>
>
>> [demime 0.98b removed an attachment of type
>
>> application/pgp-signature which had a name of PGP.sig]
>
>> _______________________________________________
>
>> darwin-kernel mailing list | email@hidden
>
>> Help/Unsubscribe/Archives:
>
>> http://www.lists.apple.com/mailman/listinfo/darwin-kernel
>
>> Do not post admin requests to the list. They will be ignored.
>
>
>
>
>
----------------------
>
http://stan4d.net
>
>
http://entropy.stop1984.com
_______________________________________________
darwin-kernel mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/darwin-kernel
Do not post admin requests to the list. They will be ignored.