This is the mail archive of the
mailing list for the Cygwin project.
- From: Igor Pechtchanski <pechtcha at cs dot nyu dot edu>
- To: Welly Santosa <welly at mediawaresolutions dot com>
- Cc: cygwin at cygwin dot com
- Date: Wed, 4 Dec 2002 20:04:58 -0500 (EST)
- Subject: Re: Ulimit
- Reply-to: cygwin at cygwin dot com
On Thu, 5 Dec 2002, Welly Santosa wrote:
> 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:
trap "kill -9 $WPID" INT
(sleep $duration; kill -9 $WPID) > /dev/null 2>&1 &
kill -9 $SPID
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...
|\ _,,,---,,_ firstname.lastname@example.org
ZZZzz /,`.-'`' -. ;-;;,_ email@example.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