?

Log in

No account? Create an account
I cannot think of a utility in *nix that you can use to run a program… - CERisE's Testing for L

> Recent Entries
> Archive
> Friends
> Profile

June 14th, 2010


Previous Entry Share Next Entry
03:41 am
I cannot think of a utility in *nix that you can use to run a program for a specified time. That is, to run an mplayer stream for a minute and then kill it.

So I wrote one.
http://l.armory.com/~cerise/alarm

(7 comments | Leave a comment)

Comments:


[User Picture]
From:aatheus
Date:June 15th, 2010 07:36 pm (UTC)
(Link)
I believe that the ulimit command can be used to do the same thing. There is a "max CPU time allowed" option. For something CPU-intensive like mplayer, it's equivalent.
[User Picture]
From:testing4l
Date:June 15th, 2010 11:26 pm (UTC)
(Link)
mplayer is also I/O intensive -- it has to read those media files and write to devices -- and that I/O time causes it to spend a lot of time in a waiting state where it does not accumulate CPU time.

In the course of playing around three seconds of a FLAC just now, mplayer accumulated about half a second of CPU time.

In any event, CPU time and wall time are very rarely equivalent which limits the feasability of using ulimit. Never mind that the relationship between the two is also affected by how busy the system is at the time.
[User Picture]
From:aatheus
Date:June 15th, 2010 11:38 pm (UTC)
(Link)
True. The I/O wait time will detract from the utility of using ulimit that way.

A feature that would be nice to have in ulimit is a 'max time to exist in the process table' option.
[User Picture]
From:testing4l
Date:June 15th, 2010 11:47 pm (UTC)
(Link)
Yeah -- it would be the most likely candidate for this functionality. Sadly, there's two reasons it's not likely to happen. For one, bash implements its own internal version of it. Secondly, its options are specified by POSIX.

> Go to Top
LiveJournal.com