+ SECURITYD_PORTS_DEAD_SESSION(port);
+}
+
+
+//
+// Handling signals.
+// These are sent as Mach messages from ourselves to escape the limitations of
+// the signal handler environment.
+//
+kern_return_t self_server_handleSignal(mach_port_t sport,
+ mach_port_t taskPort, int sig)
+{
+ try {
+ SECURITYD_SIGNAL_HANDLED(sig);
+ if (taskPort != mach_task_self()) {
+ Syslog::error("handleSignal: received from someone other than myself");
+ return KERN_SUCCESS;
+ }
+ switch (sig) {
+ case SIGCHLD:
+ ServerChild::checkChildren();
+ break;
+ case SIGINT:
+ SECURITYD_SHUTDOWN_NOW();
+ Syslog::notice("securityd terminated due to SIGINT");
+ _exit(0);
+ case SIGTERM:
+ Server::active().beginShutdown();
+ break;
+ case SIGPIPE:
+ fprintf(stderr, "securityd ignoring SIGPIPE received");
+ break;
+
+#if defined(DEBUGDUMP)
+ case SIGUSR1:
+ NodeCore::dumpAll();
+ break;
+#endif //DEBUGDUMP
+
+ case SIGUSR2:
+ {
+ extern PCSCMonitor *gPCSC;
+ gPCSC->startSoftTokens();
+ break;
+ }
+
+ default:
+ assert(false);
+ }
+ } catch(...) {
+ secdebug("SS", "exception handling a signal (ignored)");
+ }
+ mach_port_deallocate(mach_task_self(), taskPort);
+ return KERN_SUCCESS;
+}
+
+
+kern_return_t self_server_handleSession(mach_port_t sport,
+ mach_port_t taskPort, uint32_t event, uint64_t ident)
+{
+ try {
+ if (taskPort != mach_task_self()) {
+ Syslog::error("handleSession: received from someone other than myself");
+ return KERN_SUCCESS;
+ }
+ if (event == AUE_SESSION_CLOSE)
+ Session::destroy(ident);
+ } catch(...) {
+ secdebug("SS", "exception handling a signal (ignored)");
+ }
+ mach_port_deallocate(mach_task_self(), taskPort);
+ return KERN_SUCCESS;