05-09-2016
Let me explain how limits really work. When a new process is created, limits.conf is not checked -- the process just gets the same ulimit settings as the process which created it. This is quite similar to how environment variables work, where it just gets a copy. After creation, each process is independent.
When the system starts, it runs init, which starts off every other process. It's possible to change ulimit settings here, but often isn't -- changing them here could have drastic consequences since every other process on the system would inherit them!
Among a few other things, init runs sysvinit or something like it, which begins the process of starting all your system services. This is where limits.conf starts being useful: As part of this process, each executable gets limits looked up and settings set for it before it's run.
init -> sysvinit -> look up filename in limits.conf -> Apply limits -> launch filename
The important thing is, limits are set by the parent process, before the child is created. If you're not what's running executablename, you can't change its limits, only your own and whatever processes you create.
You need to figure out this chain:
init -> sysvinit -> ??? service, or cron, or a login, what? -> process Y
...because the limit settings are applied there, when ??? is created. Not when you alter limits.conf -- when the ??? process is created.
Depending on what ??? is, it's entirely possible you could shove a ulimit line in there somewhere without doing drastic changes to limits.conf. This is what I'd recommend anyway, changing your limits globally could have big consequences.
6 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
All,
How can I enable largefiles in one of the filesytems in Sun OS 5.9 ?
ls -l
-rw-r--r-- 1 oracle dba 2548163397 Dec 3 02:57 TT_TT_full.dmp.Z
cp -p TT_TT_full.dmp.Z /exports/tt/
cp: TT_TT_full.dmp.Z: File too large
ulimit -a
time(seconds) unlimited
file(blocks) ... (1 Reply)
Discussion started by: win_vin
1 Replies
2. UNIX for Advanced & Expert Users
Hi,
as per my Unix admin all parameters in Ulimit are set to Unlimited in Hard limits but some how few profiles setting data segment part to limited number value. So i wanted to over write in my profile to set unlimited as hard limits are set to unlimited. What is the command to set ulimit for... (1 Reply)
Discussion started by: terala_s
1 Replies
3. HP-UX
Hi,
I want to set the coredump to unlimited, but it seems it does not work.
> ulimit -a
time(seconds) unlimited
file(blocks) unlimited
data(kbytes) 1048576
stack(kbytes) 131072
memory(kbytes) unlimited
coredump(blocks) 4194303... (1 Reply)
Discussion started by: mr_andrew
1 Replies
4. Red Hat
Hello
Im using redhat and try to debug my application , its crashes and in strace I also see it has problems , but I can't see any core dump
I configured all the limit ( im using .cshrc ) and it looks like this :
cputime unlimited
filesize unlimited
datasize unlimited... (8 Replies)
Discussion started by: umen
8 Replies
5. Solaris
Hi Admins,
HOW to set unlimited login attempts for user in Solaris ?
And do I need to insatll any packages before doing this?
Thanks. (1 Reply)
Discussion started by: manalisharmabe
1 Replies
6. Homework & Coursework Questions
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
I'm trying to get an unlimited input of words with an unlimited number characters from the user using
malloc... (3 Replies)
Discussion started by: Joshuarodriguez
3 Replies
ULIMIT(3) BSD Library Functions Manual ULIMIT(3)
NAME
ulimit -- get and set process limits
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <ulimit.h>
long
ulimit(int cmd, ...);
DESCRIPTION
The ulimit() function will get and set process limits. Currently, this is limited to the maximum file size. The cmd argument is one of the
following:
UL_GETFSIZE will return the maximum file size of the current process, in units of 512-byte blocks.
UL_SETFSIZE will attempt to set the maximum file size of the current process and its children, using the second argument (expressed as a
long).
RETURN VALUES
Upon successful completion, ulimit() returns the value requested; otherwise, the value -1 is returned and the global variable errno is set to
indicate the error.
ERRORS
The ulimit() function will fail if:
[EINVAL] The command specified was invalid.
[EPERM] The limit specified to ulimit() would have raised the maximum limit value, and the caller is not the super-user.
SEE ALSO
getrlimit(2)
STANDARDS
The ulimit() function conforms to IEEE Std 1003.1-2001 (``POSIX.1'').
HISTORY
The ulimit() function first appeared in FreeBSD 5.0.
BUGS
The ulimit() function provides limited precision for setting and retrieving process limits. If there is a need for greater precision than
the type long provides, the getrlimit(2) and setrlimit(2) functions should be considered.
BSD
January 4, 2003 BSD