- FOR_EACH_SLOT(i) {
- struct slot_info *s = slot + i;
- if (!must_close_slot(i))
- continue;
- PARA_INFO_LOG("closing slot %d\n", i);
- close_writers(s);
- close_filters(s);
- close_receiver(i);
- clear_slot(i);
- }
+ FOR_EACH_SLOT(i)
+ if (must_close_slot(i))
+ close_slot(i);
+}
+
+/**
+ * Close the connection to para_server and exit.
+ *
+ * \param status The exit status which is passed to exit(3).
+ * \param msg The log message
+ *
+ * Log \a msg with loglevel \p EMERG, close the connection to para_server and
+ * all slots, and call \p exit(status). \a status should be either EXIT_SUCCESS
+ * or EXIT_FAILURE.
+ *
+ * \sa exit(3).
+ */
+void __noreturn clean_exit(int status, const char *msg)
+{
+ int i;
+
+ PARA_EMERG_LOG("%s\n", msg);
+ if (socket_name)
+ unlink(socket_name);
+ close_stat_pipe();
+ FOR_EACH_SLOT(i)
+ close_slot(i);
+ exit(status);