Unix socket enhanced v1.3

Here's a new PR. Only differences with previous PR, is the locking fix and a supplementary patch fixing the thread killing function.