+ kill(ppid, SIGTERM);
+
+ chdir("/");
+ fcloseall();
+}
+
+/*
+ Close network connections, and terminate neatly
+*/
+void cleanup_and_exit(int c)
+{
+cp
+ close_network_connections();
+
+ if(debug_lvl > DEBUG_NOTHING)
+ syslog(LOG_INFO, _("Total bytes written: tap %d, socket %d; bytes read: tap %d, socket %d"),
+ total_tap_out, total_socket_out, total_tap_in, total_socket_in);
+
+ closelog();
+ kill(ppid, SIGTERM);
+ exit(c);
+}
+
+/*
+ check for an existing tinc for this net, and write pid to pidfile
+*/
+int write_pidfile(void)
+{
+ int pid;
+cp
+ if((pid = check_pid(pidfilename)))