thin
thin copied to clipboard
Thin fails to daemonize if a pid is reused as a tid
Thin fails to daemonize if a pid is reused as a tid, as in the following example.
$ thin start
...
/usr/lib/ruby/vendor_ruby/thin/daemonizing.rb:171:in `remove_stale_pid_file': tmp/pids/thin.3000.pid already exists, seems like it's already running (process ID: 1215). Stop the process or delete tmp/pids/thin.3000.pid. (Thin::PidFileExist)
from /usr/lib/ruby/vendor_ruby/thin/daemonizing.rb:42:in `daemonize'
from /usr/lib/ruby/vendor_ruby/thin/controllers/controller.rb:61:in `start'
from /usr/lib/ruby/vendor_ruby/thin/runner.rb:185:in `run_command'
from /usr/lib/ruby/vendor_ruby/thin/runner.rb:151:in `run!'
from /usr/bin/thin:6:in `<main>'
$ ps -efT | grep 1215
mysql 1181 1215 1 0 Sep28 ? 00:03:42 /usr/sbin/mysqld
...
Currently Process.running? method in daemonizing.rb uses Process.getpgid() != -1, but this check is incorrect because getpgid() succeeds for a valid tid.
Please open a PR to fix.