Skip to content
This repository was archived by the owner on Jul 15, 2026. It is now read-only.
This repository was archived by the owner on Jul 15, 2026. It is now read-only.

Thin fails to daemonize if a pid is reused as a tid #451

Description

@relent95

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions