Removal of pid file can cause error

I ran into the same issue that #497 was trying to fix, but I don't think the merged solution will work.  The problem is that the old pid file is owned by the previous user(abc123 in #497) and thus, the file cannot be removed by the new user (xyz789).  A solution is to check if the current user owns the file and only performs the chmod if that is the case.  
Are uids and gids comparable?