Why does the max filesize limit shows only half value if set and executed through the script?

Solution Verified - Updated -

Issue

  • Why does the max filesize limit shows only half value if set and executed through the script?
  • Setting ulimit -f <somevalue> in a script and running a process from the same, that process shows exactly the half value of the set value in ulimit -f output, why?
  • See the example below.
[root@localhost ~]# cat test.sh 
ulimit -f 1000
echo " Let's see what's the ulimit value as of now, running commands, please wait!"
sleep 1
echo " The initial value of ulimit for filesize is `ulimit -f` "
sleep 1
echo " Setting up the new ulimit value now: For filesize its 512000 - The New One!"
ulimit -f 512000
sleep 1
echo " Successfully set the new ulimit value for filesize as `ulimit -f` "
sleep 1
echo " Running sleep now"
sleep 1000 & 

[root@localhost ~]# sh test.sh 

 Let's see what's the ulimit value as of now, running commands, please wait!
 The initial value of ulimit for filesize is 1000 
 Setting up the new ulimit value now: For filesize its 512000 - The New One!
 Successfully set the new ulimit value for filesize as 512000 
 Running sleep now

[root@localhost ~]# ps -ef | grep sleep
root      2393     1  0 17:00 pts/0    00:00:00 sleep 1000
root      2395  2127  0 17:00 pts/0    00:00:00 grep sleep

[root@localhost ~]# cat /proc/2393/limits | grep "Max file size"
Max file size             262144000            262144000            bytes  
  • The script has set the ulimit -f to 512000 but the process is taking only of it's half (exactly half) i.e. 512000*1024=524288000 shall be the value, but its 524288000/2 = 262144000.
  • Is this a bug? Is there any workaround?

Environment

  • Red Hat Enterprise Linux (RHEL) 6.5

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content