summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-07 14:12:04 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-07 14:12:04 +0000
commit34bb945c40beb9998e3e33ed603a5841826128c5 (patch)
tree94512da7bd44ad0ba489c205882ee9a03eb9a368 /test
parentfe6273975eb7a8b8bbc48ef62dc74b7a1a8c10e8 (diff)
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
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_rubyoptions.rb19
1 files changed, 19 insertions, 0 deletions
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