* At one time, canaries were carried along with coal miners down
* into a mine. Their purpose was to alert the miners when they
* had drilled into a pocket of methane gas or another noxious
- * substance. The canary, being the most sensitive animal would
+ * substance. The canary, being the most sensitive animal, would
* immediately fall over. Seeing this, the miners could take
* action to escape the mine, seeing an imminent danger.
*
* the same time. This is also why this canary must exist as a
* completely separate process and not simply as a thread within
* Asterisk itself.
+ *
+ * Quote:
+ * "The nice value set with setpriority() shall be applied to the
+ * process. If the process is multi-threaded, the nice value shall
+ * affect all system scope threads in the process."
+ *
+ * Source:
+ * http://www.opengroup.org/onlinepubs/000095399/functions/setpriority.html
+ *
+ * In answer to the question, what aren't system scope threads, the
+ * answer is, in Asterisk, nothing. Process scope threads are the
+ * alternative, but they aren't supported in Linux.
*/
const char explanation[] =
int fd;
/* Run at normal priority */
setpriority(PRIO_PROCESS, 0, 0);
- for (;;) {
+ for (; getppid() != 1;) {
/* Update the modification times (checked from Asterisk) */
if (utime(argv[1], NULL)) {
/* Recreate the file if it doesn't exist */
sleep(5);
}
- /* Never reached */
+ /* Reached if asterisk (our parent process) dies - its chldren are inherited by the init process (pid is 1). */
return 0;
}