<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>4281</bug_id>
          
          <creation_ts>2004-06-02 20:40:16 +0400</creation_ts>
          <short_desc>ulimit -H does not change soft limit</short_desc>
          <delta_ts>2005-07-13 15:46:12 +0400</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>bash</component>
          <version>unstable</version>
          <rep_platform>all</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>NOTABUG</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Sergey Vlasov">vsu</reporter>
          <assigned_to name="placeholder@altlinux.org">placeholder</assigned_to>
          <cc>glebfm</cc>
    
    <cc>inger</cc>
    
    <cc>ldv</cc>
    
    <cc>placeholder</cc>
    
    <cc>voins</cc>
    
    <cc>vt</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>14554</commentid>
    <comment_count>0</comment_count>
    <who name="Sergey Vlasov">vsu</who>
    <bug_when>2004-06-02 20:40:16 +0400</bug_when>
    <thetext>В bash происходит следующее:

$ rpm -q bash
bash-2.05b-alt6

$ uname -r
2.6.6-std26-up-alt5

$ ulimit -Ha
core file size        (blocks, -c) unlimited
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) 1024
pipe size          (512 bytes, -p) 8
stack size            (kbytes, -s) unlimited
cpu time             (seconds, -t) unlimited
max user processes            (-u) 256
virtual memory        (kbytes, -v) unlimited

$ ulimit -H -v 2000000
bash: ulimit: virtual memory: cannot modify limit: Invalid argument

В то же время в zsh этот лимит ставится:

$ ulimit -H -v 2000000
$ ulimit -Ha
cpu time (seconds)         unlimited
file size (blocks)         unlimited
data seg size (kbytes)     unlimited
stack size (kbytes)        unlimited
core file size (blocks)    unlimited
resident set size (kbytes) unlimited
processes                  256
file descriptors           1024
locked-in-memory size (kb) unlimited
address space (kb)         2000000
file locks                 unlimited

Более того, запущенный из этого zsh bash наследует и отображает установленное
значение:

$ bash -c &apos;ulimit -Ha&apos;
core file size        (blocks, -c) unlimited
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) 1024
pipe size          (512 bytes, -p) 8
stack size            (kbytes, -s) unlimited
cpu time             (seconds, -t) unlimited
max user processes            (-u) 256
virtual memory        (kbytes, -v) 2000000

С ulimit -Sv ситуация аналогичная.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>14555</commentid>
    <comment_count>1</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2004-06-02 20:45:33 +0400</bug_when>
    <thetext>Unable to reproduce.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>14557</commentid>
    <comment_count>2</comment_count>
    <who name="Sergey Vlasov">vsu</who>
    <bug_when>2004-06-02 21:12:33 +0400</bug_when>
    <thetext>strace output for bash:

getrlimit(RLIMIT_AS, {rlim_cur=RLIM_INFINITY, rlim_max=RLIM_INFINITY}) = 0
getrlimit(RLIMIT_AS, {rlim_cur=RLIM_INFINITY, rlim_max=RLIM_INFINITY}) = 0
setrlimit(RLIMIT_AS, {rlim_cur=RLIM_INFINITY, rlim_max=2000000*1024}) = -1
EINVAL (Invalid argument)
open(&quot;/usr/share/locale/ru_RU.KOI8-R/LC_MESSAGES/libc.mo&quot;, O_RDONLY) = -1 ENOENT
(No such file or directory)
open(&quot;/usr/share/locale/ru_RU.koi8r/LC_MESSAGES/libc.mo&quot;, O_RDONLY) = -1 ENOENT
(No such file or directory)
open(&quot;/usr/share/locale/ru_RU/LC_MESSAGES/libc.mo&quot;, O_RDONLY) = -1 ENOENT (No
such file or directory)
open(&quot;/usr/share/locale/ru.KOI8-R/LC_MESSAGES/libc.mo&quot;, O_RDONLY) = -1 ENOENT
(No such file or directory)
open(&quot;/usr/share/locale/ru.koi8r/LC_MESSAGES/libc.mo&quot;, O_RDONLY) = -1 ENOENT (No
such file or directory)
open(&quot;/usr/share/locale/ru/LC_MESSAGES/libc.mo&quot;, O_RDONLY) = -1 ENOENT (No such
file or directory)
write(2, &quot;sh: line 1: ulimit: virtual memo&quot;..., 74sh: line 1: ulimit: virtual
memory: cannot modify limit: Invalid argument
) = 74
exit_group(1)                           = ?

strace output for zsh:
setrlimit(RLIMIT_AS, {rlim_cur=2000000*1024, rlim_max=2000000*1024}) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [CHLD], 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [CHLD], [CHLD], 8) = 0
getpid()                                = 23961
exit_group(0)                           = ?
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>14558</commentid>
    <comment_count>3</comment_count>
    <who name="Sergey Vlasov">vsu</who>
    <bug_when>2004-06-02 21:14:24 +0400</bug_when>
    <thetext>Oops- про ulimit -Sv наврал - он работает.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>14559</commentid>
    <comment_count>4</comment_count>
    <who name="Sergey Vlasov">vsu</who>
    <bug_when>2004-06-02 21:22:49 +0400</bug_when>
    <thetext>Как оказалось, 2.4.26-std-smp-alt2 ведёт себя точно так же:

$ ulimit -Hv 500000 
-bash: ulimit: virtual memory: cannot modify limit: Invalid argument

strace:
setrlimit(RLIMIT_AS, {rlim_cur=1048576*1024, rlim_max=500000*1024}) = -1 EINVAL
(Invalid argument)

Судя по http://www.opengroup.org/onlinepubs/007908799/xsh/getrlimit.html, ядро в
данном случае ведёт себя правильно:

The getrlimit() and setrlimit() functions will fail if:

[EINVAL]
    An invalid resource was specified; or in a setrlimit() call, the new
rlim_cur exceeds the new rlim_max.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>14560</commentid>
    <comment_count>5</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2004-06-02 21:23:49 +0400</bug_when>
    <thetext>Это от ядра не зависит.
Если сначала не выставить -Sv, то -Hv не сработает.

Вопрос в том, что должна делать команда ulimit c soft limit&apos;ом при установке hard
limit&apos;а, и должна ли вообще?

См. тж.:
$ ulimit -Sv 262144
$ ulimit -Hv 262144
$ ulimit -Hv 262143
bash: ulimit: virtual memory: cannot modify limit: Invalid argument
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>14561</commentid>
    <comment_count>6</comment_count>
    <who name="Sergey Vlasov">vsu</who>
    <bug_when>2004-06-02 21:33:49 +0400</bug_when>
    <thetext>Мда... очередной случай несовместимости shell-ов.

bash:
   If neither -H nor -S is specified, both the soft and hard limits are set.

zsh:
   By default, only soft limits are manipulated.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>14562</commentid>
    <comment_count>7</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2004-06-02 21:45:36 +0400</bug_when>
    <thetext>Короче говоря, это не ошибка, а просто очередная особенность.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>14598</commentid>
    <comment_count>8</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2004-06-03 15:32:38 +0400</bug_when>
    <thetext>Я убеждён, что поведение bash логичнее, чем избыточный интеллект zsh.
Все присутствующие в данный момент в офисе со мной в этом согласны.

Если надо установить оба лимита сразу, есть &quot;ulimit -SH&quot;.

Неплохо бы повесить PR на zsh.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>