static void DontStart(void) { FILE *tty; FILE *log; __pmNotifyErr(LOG_ERR, "pmcd not started due to errors!\n"); if ((tty = fopen(fatalfile, "w")) != NULL) { fflush(stderr); fprintf(tty, "NOTE: pmcd not started due to errors! "); if ((log = fopen(logfile, "r")) != NULL) { int c; fprintf(tty, "Log file \"%s\" contains ...\n", logfile); while ((c = fgetc(log)) != EOF) fputc(c, tty); fclose(log); } else fprintf(tty, "Log file \"%s\" has vanished!\n", logfile); fclose(tty); } /* * We are often called after the request ports have been opened. If we don't * explicitely close them, then the unix domain socket file (if any) will be * left in the file system, causing "address already in use" the next time * pmcd starts. */ __pmServerCloseRequestPorts(); exit(1); }
/* Called to shutdown pmproxy in an orderly manner */ void Shutdown(void) { int i; for (i = 0; i < nClients; i++) if (client[i].status.connected) __pmCloseSocket(client[i].fd); __pmServerCloseRequestPorts(); __pmSecureServerShutdown(); __pmNotifyErr(LOG_INFO, "pmproxy Shutdown\n"); fflush(stderr); }
void Shutdown(void) { int i; for (i = 0; i < nAgents; i++) { AgentInfo *ap = &agent[i]; if (!ap->status.connected) continue; if (ap->inFd != -1) { if (__pmSocketIPC(ap->inFd)) __pmCloseSocket(ap->inFd); else close(ap->inFd); } if (ap->outFd != -1) { if (__pmSocketIPC(ap->outFd)) __pmCloseSocket(ap->outFd); else close(ap->outFd); } if (ap->ipcType == AGENT_SOCKET && ap->ipc.socket.addrDomain == AF_UNIX) { /* remove the Unix domain socket */ unlink(ap->ipc.socket.name); } } if (HarvestAgents(SHUTDOWNWAIT) < 0) { /* terminate with prejudice any still remaining */ for (i = 0; i < nAgents; i++) { AgentInfo *ap = &agent[i]; if (ap->status.connected) { pid_t pid = ap->ipcType == AGENT_SOCKET ? ap->ipc.socket.agentPid : ap->ipc.pipe.agentPid; __pmProcessTerminate(pid, 1); } } } for (i = 0; i < nClients; i++) if (client[i].status.connected) __pmCloseSocket(client[i].fd); __pmServerCloseRequestPorts(); __pmSecureServerShutdown(); __pmNotifyErr(LOG_INFO, "pmcd Shutdown\n"); fflush(stderr); }
void Shutdown(void) { AgentInfo *ap, *root = NULL; int i; for (i = 0; i < nAgents; i++) { ap = &agent[i]; if (ap->pmDomainId == PMDAROOT) root = ap; if (ap->status.isRootChild) ShutdownAgent(ap); } for (i = 0; i < nAgents; i++) { ap = &agent[i]; if (ap->pmDomainId == PMDAROOT) continue; if (!ap->status.isRootChild) ShutdownAgent(ap); } if (HarvestAgents(SHUTDOWNWAIT) < 0) { /* terminate with prejudice any still remaining non-root PMDAs */ for (i = 0; i < nAgents; i++) { ap = &agent[i]; if (ap == root) continue; TerminateAgent(ap); } } if (root) { TerminateAgent(root); ShutdownAgent(root); HarvestAgents(0); } for (i = 0; i < nClients; i++) { if (client[i].status.connected) __pmCloseSocket(client[i].fd); } __pmServerCloseRequestPorts(); __pmSecureServerShutdown(); __pmNotifyErr(LOG_INFO, "pmcd Shutdown\n"); fflush(stderr); }