osdep: shorten thread name on glibc only

Instead of affecting every platform, do this for glibc only (where it's
known to be a problem), and only if the right error is returned.
command: allow sub_add at an earlier stage
command: remove hook cancellation mechanism

I doubt anyone will actually use this correctly. Also, there was a bug
(a typo) which prevented it from working at all.
command: extend sub_add command
lua: add convenience function for hooks

So the user doesn't have to care about the awkward low-level details.