From: Dan Zwell Date: 2007-04-15T16:08:45+09:00 Subject: Re: executing a system command and stopping it after a specified duration? -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Robert La Ferla wrote: > I'd like to run a system command and then stop it after specified amount > of time (in seconds or milliseconds.) What's the best way to do it? > > e.g. > > exec("cat /dev/video > test.mpg") > > then kill the process after so many minutes, seconds, etc... > > Also, if there is a better Ruby way to do this other than "cat", I'm all > ears... > > Thanks. > > > > # from "ri Timeout": require 'timeout' status = Timeout::timeout(500) { exec("cat /dev/video > test.mpg") } Dan -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGId0kUYnvW+YuEvYRAkc0AKDBBveie/L0/2ePNqkLKYKvqz4fTACgso+d g3U+yVpF+5pFf3RnGb+fS9o= =B+zE -----END PGP SIGNATURE-----