zsh-workers
 help / color / mirror / code / Atom feed
From: David Peer <davidpeer@cs.huji.ac.il>
To: zsh-workers@sunsite.dk
Subject: Re: Bug in ulimit ?
Date: Tue, 17 Apr 2007 16:57:45 +0300	[thread overview]
Message-ID: <4624D259.1070300@cs.huji.ac.il> (raw)
In-Reply-To: <4624D1AA.4030902@cs.huji.ac.il>

I forgot:

The file that needs to be changed, of-course is: kernel/sys.c

It was check on kernel 2.6.20.3


David

David Peer wrote:

> I hope kernel people will add it to the next kernel release,
>
> but here is one rapid fix that solves the problem.
>
> (you will not see the new limit of 1 sec but you'll still see it set 
> to 0, but its 1 sec - believe me && try,
>
> if you want to see it, fork another any shell and you'll see it....bug 
> or feature?!)
>
>
> Before the line: *old_rlim = new_rlim;
>
>
> add:
>
>
> if (resource == RLIMIT_CPU && new_rlim.rlim_cur == 0) {
>            /*
>             * The caller is asking for an immediate RLIMIT_CPU
>             * expiry.  But we use the zero value to mean "it was
>             * never set".  So let's cheat and make it one second
>             * instead
>             */
>            new_rlim.rlim_cur = 1;
>        }
>
>
> You can remove the dumb if statement that does nothing cause the 
> assignment occurs(*old_rlim = new_rlim) before
>
> so it has no meaning! : if (rlim_cur == 0) {....}
>
>
> David
>
>
>
> Stephane Chazelas wrote:
>
>> On Tue, Apr 17, 2007 at 02:24:46PM +0100, Stephane Chazelas wrote:
>>  
>>> On Tue, Apr 17, 2007 at 02:03:16PM +0100, Stephane Chazelas wrote:
>>> [...]
>>>    
>>>> So it would seem that the limit is inherited but not applied in
>>>> the child (and I couldn't see any signal being blocked or
>>>> ignored). So that's probably not a libc issue, rather a Linux
>>>> issue.
>>>>       
>>> [...]
>>>     
>>
>> Please ignore this email, I was talking rubbish again, I should
>> probably get back to sleep....
>>
>>  
>>> The Linux code for setrlimit gives a hint:
>>>
>>>         if (it_prof_secs == 0 || new_rlim.rlim_cur <= it_prof_secs) {
>>>                 unsigned long rlim_cur = new_rlim.rlim_cur;
>>>                 cputime_t cputime;
>>>
>>>                 if (rlim_cur == 0) {
>>>                         /*
>>>                          * The caller is asking for an immediate 
>>> RLIMIT_CPU
>>>                          * expiry.  But we use the zero value to 
>>> mean "it was
>>>                          * never set".  So let's cheat and make it 
>>> one second
>>>                          * instead
>>>                          */
>>>                         rlim_cur = 1;
>>>                 }
>>>
>>> It's stored as being "0" and armed with a 1 second delay. And on a 
>>> fork,
>>> obviously, for the new process, there's no way to distinguish
>>> between a 0 that means "not set" and a 0 that means exit
>>> immediately.
>>>
>>> And one can verify that it_prof_expires will be set to 0 in
>>> copy_signal during the fork and that 0 means not armed in
>>> check_process_timers.
>>>
>>> But what's the point of setting a cputime of 0 anyway?
>>>     
>>
>>   
>
>


-- 
David Peer <!> davidpeer@cs.huji.ac.il
CS System Group | Phone: 02 - 6586942
School of Computer Science and Engineering
Hebrew University of Jerusalem - Israel
Edmund Safra Campus - Givat Ram


  reply	other threads:[~2007-04-17 13:58 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-17  9:00 David Peer
2007-04-17  9:30 ` Micah Cowan
2007-04-17  9:33   ` David Peer
2007-04-17  9:42   ` Stephane Chazelas
2007-04-17 10:04     ` Micah Cowan
2007-04-17 10:43       ` Stephane Chazelas
2007-04-17 10:55         ` Micah Cowan
2007-04-17 12:53           ` Stephane Chazelas
2007-04-17 13:03             ` Stephane Chazelas
2007-04-17 13:24               ` Stephane Chazelas
2007-04-17 13:34                 ` Stephane Chazelas
2007-04-17 13:54                   ` David Peer
2007-04-17 13:57                     ` David Peer [this message]
2007-04-17 15:02                   ` [OT] " Stephane Chazelas
2007-04-17 10:49       ` Micah Cowan
2007-04-17 14:15   ` Tom Alsberg
2007-04-17 15:48     ` David Peer
     [not found]     ` <20070417151501.GH4955@sc.homeunix.net>
2007-04-18  7:46       ` (Off-Topic) " Tom Alsberg
2007-04-18  8:22         ` Stephane Chazelas
2007-04-18  9:23           ` (Off-Topic) Bug in ulimit? Tom Alsberg
2007-04-18 10:10             ` Stephane Chazelas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4624D259.1070300@cs.huji.ac.il \
    --to=davidpeer@cs.huji.ac.il \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).