u.u_limit structure on UNIXPC
Lenny Tropiano
lenny at icus.islp.ny.us
Wed Sep 13 15:12:04 AEST 1989
In article <2725 at umn-d-ub.D.UMN.EDU> rhealey at ub.d.umn.edu (Rob Healey) writes:
|>
|> How does one set/modify the limits in the u.u_limit array for
|> the user under 3.5x? See /usr/include/sys/vlimit.h for details.
|> IS there any way you can set these so your core files, CPU time,
|> etc is actually limited? I didn't see the SIGNALS involved in
|> the limits defined anywhere. Just VERY curious if this is just
|> another dead end brought to you by Convergent and the mortal
|> remains of CTIX within the UNIX PC.
|>
Well you tweeked my curiosity, so I had to try it for myself. I started
by researching those files, <sys/vlimit.h>, <sys/user.h>, etc.. Then
I wrote a program to get the address of my user structure, then lseek in
/dev/kmem for that address and read in struct user. I dumped out the
values for u->u_limit[0..6] to see what they were...
u->u_limit[LIM_NORAISE] = 0
u->u_limit[LIM_CPU] = INFINITY (2147483647)
u->u_limit[LIM_FSIZE] = INFINITY
u->u_limit[LIM_DATA] = 2621440
u->u_limit[LIM_STACK] = 524288
u->u_limit[LIM_CORE] = INFINITY
u->u_limit[LIM_MAXRSS] = INFINITY
For what I can see the stuff like CPU time limits, core file size limits,
etc, are BSD left-overs from the Convergent port. Yes, as Rob pointed
out there is no signals to handle the limit overflows. On a BSD system
there would be a signal like SIGXCPU that would be for exceeding the CPU
time limit. The LIM_FSIZE correlates to the ulimit(2) system call,
and the ulimit built-in for /bin/sh and /bin/ksh. I tested my program
by doing a: ulimit 1000 and then re-running it and I saw that:
u->u_limit[LIM_FSIZE] = 1000
So what I did was modify the program to write the user structure back out
to kmem with some values changed. I changed the LIM_CPU to 10 (10 cpu secs)
and LIM_CORE to 2 (two blocks). I then wrote a simple program that just
looped forever and ever. It accrued minutes of cpu time, and didn't stop.
I also created a program that malloc'd as much memory as it could (sbrk(2))
and then I did a "kill -4 pid", which created a BIG core file! Definately
not two blocks ...
Now what's interesting, and I haven't really tested anything with this
yet, is the values that aren't INFINITY; LIM_DATA, LIM_STACK.
LIM_DATA is at a two megabyte limit (which sound correct), and
LIM_STACK is at a .5MB limit. Since it's late already tonight, and I'm
dead tired, I'll play with this more tomorrow. But I have a feeling
that the u_limit[] array in the user block isn't used for anything but
the file size limit. For more information on BSD only stuff, look in
the manual under ksh(1), and the built-in ulimit. I did, BTW try
doing a ulimit -c ##, and it said bad options(s) -- as suspected!
Hope that helps... It would be nice if those BSDisms were there!
-Lenny
--
Lenny Tropiano ICUS Software Systems [w] +1 (516) 589-7930
lenny at icus.islp.ny.us Telex; 154232428 ICUS [h] +1 (516) 968-8576
{ames,pacbell,decuac,hombre,talcott,sbcs}!icus!lenny attmail!icus!lenny
ICUS Software Systems -- PO Box 1; Islip Terrace, NY 11752
More information about the Unix-pc.general
mailing list