winpr: rewrite named pipe sharing

Since commit 5e09e37d42bd8896a687df830a95f5cb56e4d47c was basically unfixable,
here is a slightly different approach that should hopefully solve all
discovered issues and race conditions.

Also extended the named pipe c test.