make parse_def and parse_def_file return struct packet

fix a bug in next_char to not fallthrough in the sate machine switch
varous fixes to make serve.c compile cleanly
added paranoid checks for running and closed stdin stdout and stderr before forking.
add signal handlers to SIGINT and SIGTERM and code to create and close server unix socket in /tmp