Stubby from net-dns/getdns-1.6.0_beta1-r2 doesn't start correctly when launched by /etc/init.d/stubby init script because it is not able to create its pid file.
This init scripts starts stubby as "stubby" user, but this user has no write permissions on "/run" directory to create the pid file.
The init script tries to work it around by pre-creating an empty pid file with the correct permissions and ownership, however this doesn't matter since start-stop-daemon will remove the pid file anyway before staring its child, see here:
So by the time the stubby daemon starts the pid file is no longer there and it has no permissions to create it again.
That's why it fails to start.
A possible fix is to make stubby use the "/run/stubby/" directory for its pid file, as -r1 version of the init script did.
A patch doing this made against the init script and getdns ebuild is attached.
In addition to the above issue, it is not necessary to remove the pid file on stop action in this init script - start-stop-daemon will do it for us.
Created attachment 630886 [details, diff]
a possible fix