From 34bb945c40beb9998e3e33ed603a5841826128c5 Mon Sep 17 00:00:00 2001 From: knu Date: Wed, 7 Aug 2013 14:12:04 +0000 Subject: Add Process.setproctitle(). * ruby.c (Process.setproctitle): New method to change the title of the running process that is shown in ps(1). [Feature #8696] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_rubyoptions.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test') diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index 35422ae2ac..06c6b7337f 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -477,6 +477,25 @@ class TestRubyOptions < Test::Unit::TestCase end end + def test_setproctitle + skip "platform dependent feature" if /linux|freebsd|netbsd|openbsd|darwin/ !~ RUBY_PLATFORM + + with_tmpchdir do + write_file("test-script", "$_0 = $0.dup; Process.setproctitle('hello world'); $0 == $_0 or Process.setproctitle('$0 changed!'); sleep 60") + + pid = spawn(EnvUtil.rubybin, "test-script") + ps = nil + 10.times do + sleep 0.1 + ps = `ps -p #{pid} -o command` + break if /hello world/ =~ ps + end + assert_match(/hello world/, ps) + Process.kill :KILL, pid + Process.wait(pid) + end + end + module SEGVTest opts = {} if /mswin|mingw/ =~ RUBY_PLATFORM -- cgit v1.2.3