From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH] test/ruby/test_process.rb: test for fd=3 usability in child
Date: Sun, 5 Jul 2015 00:18:29 +0000 [thread overview]
Message-ID: <1436055509-17550-1-git-send-email-e@80x24.org> (raw)
Ensure we can redirect anything to fd=3 in a child process.
fd=3 is a commonly reserved FD for the timer thread pipe in the
parent, but fd=3 is the first FD used by the sd_listen_fds function
for systemd.
This test should ensure the continued viability of systemd
replacements in Ruby :>
---
test/ruby/test_process.rb | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb
index a43dcf4..cda4cfc 100644
--- a/test/ruby/test_process.rb
+++ b/test/ruby/test_process.rb
@@ -2029,4 +2029,29 @@ EOS
}
assert_equal(th, x)
end if defined?(fork)
+
+ def test_exec_fd_3_redirect
+ # ensure we can redirect anything to fd=3 in a child process.
+ # fd=3 is a commonly reserved FD for the timer thread pipe in the
+ # parent, but fd=3 is the first FD used by the sd_listen_fds function
+ # for systemd
+ assert_separately(['-', RUBY], <<-INPUT, timeout: 60)
+ ruby = ARGV.shift
+ begin
+ assert_raises(ArgumentError) { IO.for_fd(3) }
+ a = IO.pipe
+ b = IO.pipe
+ pid = fork do
+ exec ruby, '-e', 'print IO.for_fd(3).read(1)', 3 => a[0], 1 => b[1]
+ end
+ b[1].close
+ a[0].close
+ a[1].write('.')
+ assert_equal ".", b[0].read(1)
+ ensure
+ a.each(&:close) if a
+ b.each(&:close) if b
+ end
+ INPUT
+ end if defined?(fork)
end
--
EW
next reply other threads:[~2015-07-05 0:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-05 0:18 Eric Wong [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-07-05 0:20 [PATCH] test/ruby/test_process.rb: test for fd=3 usability in child 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1436055509-17550-1-git-send-email-e@80x24.org \
--to=e@80x24.org \
--cc=spew@80x24.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.
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).