From: Eric Wong <e@80x24.org>
To: dtas-all@nongnu.org
Subject: [PATCH 2/3] use CPU rlimit to limit soxi||ffprobe run time
Date: Fri, 26 Apr 2024 07:04:14 +0000 [thread overview]
Message-ID: <20240426070416.497972-3-e@80x24.org> (raw)
In-Reply-To: <20240426070416.497972-1-e@80x24.org>
soxi or ffprobe may infinite loop on bad files, so be sure to
let these processes timeout properly.
---
bin/dtas-readahead | 2 +-
lib/dtas/source/av_ff_common.rb | 2 +-
lib/dtas/source/sox.rb | 3 ++-
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/bin/dtas-readahead b/bin/dtas-readahead
index f2ab514..c61d317 100755
--- a/bin/dtas-readahead
+++ b/bin/dtas-readahead
@@ -25,7 +25,7 @@
c = DTAS::UNIXClient.new
@max_ra = 30 * 1024 * 1024
null = DTAS.null
-@redir = { err: null, out: null, in: null }.freeze
+@redir = { err: null, out: null, in: null, rlimit_cpu: [ 1, 2 ] }.freeze
require 'pp'
def seek_to_cur_pos(cur_pid, fp)
diff --git a/lib/dtas/source/av_ff_common.rb b/lib/dtas/source/av_ff_common.rb
index c600c48..7f197e0 100644
--- a/lib/dtas/source/av_ff_common.rb
+++ b/lib/dtas/source/av_ff_common.rb
@@ -92,7 +92,7 @@ def av_ff_ok?
err = "".b
begin
- s = qx(@env, cmd, err_str: err, no_raise: true)
+ s = qx(@env, cmd, err_str: err, no_raise: true, rlimit_cpu: [ 1, 2 ])
rescue Errno::ENOENT # avprobe/ffprobe not installed
return false
end
diff --git a/lib/dtas/source/sox.rb b/lib/dtas/source/sox.rb
index c03477e..365c7b6 100644
--- a/lib/dtas/source/sox.rb
+++ b/lib/dtas/source/sox.rb
@@ -39,7 +39,8 @@ def initialize(mcache = nil)
def mcache_lookup(infile)
(@mcache ||= DTAS::Mcache.new).lookup(infile) do |input, dst|
err = ''.b
- out = qx(@env.dup, %W(soxi #{input}), err_str: err, no_raise: true)
+ out = qx(@env.dup, %W(soxi #{input}), err_str: err, no_raise: true,
+ rlimit_cpu: [ 1, 2 ])
return soxi_failed(infile, out) if Process::Status === out
return soxi_failed(infile, err) if err =~ /soxi FAIL formats:/
out =~ /^Duration\s*:[^=]*= (\d+) samples /n
next prev parent reply other threads:[~2024-04-26 7:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-26 7:04 [PATCH 0/3] a small pile of miscellany Eric Wong
2024-04-26 7:04 ` [PATCH 1/3] source/sox: use Process::Status#inspect for diagnostics Eric Wong
2024-04-26 7:04 ` Eric Wong [this message]
2024-04-26 7:04 ` [PATCH 3/3] splitfx: support tshift directive Eric Wong
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
List information: https://80x24.org/dtas/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240426070416.497972-3-e@80x24.org \
--to=e@80x24.org \
--cc=dtas-all@nongnu.org \
/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://80x24.org/dtas.git/
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 read-only IMAP folder(s) and NNTP newsgroup(s).