23 #include <sys/types.h>
26 #include <sys/resource.h>
79 static const char explanation[] =
80 "This file is created when Asterisk is run with a realtime priority (-p). It\n"
81 "must continue to exist, and the astcanary process must be allowed to continue\n"
82 "running, or else the Asterisk process will, within a short period of time,\n"
83 "slow itself down to regular priority.\n\n"
84 "The technical explanation for this file is to provide an assurance to Asterisk\n"
85 "that there are no threads that have gone into runaway mode, thus hogging the\n"
86 "CPU, and making the Asterisk machine seem to be unresponsive. When that\n"
87 "happens, the astcanary process will be unable to update the timestamp on this\n"
88 "file, and Asterisk will notice within 120 seconds and react. Slowing the\n"
89 "Asterisk process down to regular priority will permit an administrator to\n"
90 "intervene, thus avoiding a need to reboot the entire machine.\n";
92 int main(
int argc,
char *argv[])
98 fprintf(stderr,
"Usage: %s <monitor-filename> <ppid>\n", argv[0]);
103 setpriority(PRIO_PROCESS, 0, 0);
113 for (parent = atoi(argv[2]); parent == getppid() ;) {
115 if (utime(argv[1], NULL)) {
117 if ((fd = open(argv[1], O_RDWR | O_TRUNC | O_CREAT, 0777)) > -1) {
118 if (write(fd, explanation, strlen(explanation)) < 0) {
int main(int argc, char *argv[])