delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/12/05/18:55:36

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs
Date: Thu, 5 Dec 2002 18:55:20 -0500 (EST)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: Welly Santosa <welly AT mediawaresolutions DOT com>
cc: cygwin AT cygwin DOT com
Subject: Re: Ulimit
In-Reply-To: <3DEEBE4C.8020307@mediawaresolutions.com>
Message-ID: <Pine.GSO.4.44.0212051851430.29289-100000@slinky.cs.nyu.edu>
Importance: Normal
MIME-Version: 1.0

Welly,

This is quite possible, as the script was written along with the message,
with no testing.  You would have a much better chance of debugging it
yourself.  Some things to check are:
- whether 2304 is the WPID or the SPID,
- whether the process that you're timing completes,
- whether the trap is executed,
- whether the process you're trying to kill spawns other processes.

The list above is almost certainly incomplete, but it provides a good
starting set.
	Igor

On Thu, 5 Dec 2002, Welly Santosa wrote:

> Igor,
>
> Thanks for your reply. I have tried your suggestion, and I got this
> error message saying that:
>
>     kill 2304: Operation not permitted
>
> where 2304 being the PID. Any more suggestion?
>
> Thank you,
>
> Welly
>
> Igor Pechtchanski wrote:
>
> >On Thu, 5 Dec 2002, Welly Santosa wrote:
> >
> >>Hi,
> >>
> >>I would like to set the maximum CPU time into a few minutes only. When I
> >>tried to use ulimit (using CYGWIN), it gave me this:
> >>
> >>$ ulimit -t 100
> >>bash: ulimit: cpu time: cannot modify limit: Invalid argument
> >>
> >>So, is this option not supported? if not, is there any other option
> >>where I can limit one process to be able to run
> >>for only a limited amount of time?
> >>
> >>PS: The reason for me doing this is so that I can check whether a
> >>process loops forever.
> >>Thank you in advance.
> >>
> >>Best regards,
> >>
> >>Welly Santosa
> >>Software Engineer
> >>Mediaware Solutions Pty Ltd.
> >
> >As far as I'm aware, ulimit doesn't work on Cygwin, sorry.
> >However, yours is the easiest case to implement without ulimit: use a
> >deadman timer, something like this:
> >
> >       #!/bin/sh
> >       process-to-check &
> >       WPID=$!
> >       trap "kill -9 $WPID" INT
> >       (sleep $duration; kill -9 $WPID) > /dev/null 2>&1 &
> >       SPID=$!
> >       wait $WPID
> >       RES=$?
> >       kill -9 $SPID
> >       exit $RES
> >
> >where 'process-to-check' is the process you want to limit, and 'duration'
> >is the time limit (in seconds) that you want to impose.  You may need to
> >do something more sophisticated if your process can spawn other processes.
> >
> >Hope this helps...
> >       Igor

-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor AT watson DOT ibm DOT com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"Water molecules expand as they grow warmer" (C) Popular Science, Oct'02, p.51


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019