libctd: Parse command line options and daemonize if being asked

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
libctd: Write pidfile

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
libctd: Prepare erguments for exec before calling it

When arrived from protobuf, the argv array is not NULL-terminated,
instead we have the n_foo field telling us how much args are there.
The execv() needs NULL at the end, so reshuffle the arguments to
have such.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
test: Add spawn_exec test via libctd

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>