+ while(1) {
+ do {
+ did_something = 0;
+ tv.tv_sec = HOUSEKEEPING_WAKEUP;
+ tv.tv_usec = 0;
+ FD_ZERO(&readfds);
+ FD_SET(housepipe[0], &readfds);
+ select(housepipe[0] + 1, &readfds, 0L, 0L, &tv);
+ if (FD_ISSET(housepipe[0], &readfds)) {
+ did_something = 1;
+ }
+
+ if (did_something) {
+ read(housepipe[0], house_cmd, 256);
+ }
+ else {
+ memset(house_cmd, 0, 256);
+ strcpy(house_cmd, "MINUTE");
+ }
+
+
+ /* Do whatever this cmd requires */
+ if (!strcmp(house_cmd, "MINUTE")) {
+ terminate_idle_sessions();
+ }
+
+ else if (!strcmp(house_cmd, "SCHED_SHUTDOWN")) {
+ check_sched_shutdown();
+ }
+
+ else {
+ lprintf(7, "Unknown housekeeping command\n");
+ }
+
+ } while (did_something);
+ }
+}
+
+
+
+
+
+
+void enter_housekeeping_cmd(char *cmd) {
+ char cmdbuf[256];
+
+ safestrncpy(cmdbuf, cmd, 256);
+ begin_critical_section(S_HOUSEKEEPING);
+ write(housepipe[1], cmdbuf, 256);
+ end_critical_section(S_HOUSEKEEPING);
+}
+