[asterisk-commits] tilghman: branch 1.6.0 r178304 - in /branches/1.6.0: ./ utils/astcanary.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Feb 24 11:53:16 CST 2009


Author: tilghman
Date: Tue Feb 24 11:53:16 2009
New Revision: 178304

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=178304
Log:
Merged revisions 178303 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
  r178303 | tilghman | 2009-02-24 11:51:36 -0600 (Tue, 24 Feb 2009) | 7 lines
  
  Cause astcanary to exit if Asterisk exits abnormally and doesn't kill astcanary.
  Also, add some documentation supporting the use of astcanary.
  (closes issue #14538)
   Reported by: KNK
   Patches: 
         asterisk-1.6.x-astcanary.diff uploaded by KNK (license 545)
........

Modified:
    branches/1.6.0/   (props changed)
    branches/1.6.0/utils/astcanary.c

Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.0/utils/astcanary.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.6.0/utils/astcanary.c?view=diff&rev=178304&r1=178303&r2=178304
==============================================================================
--- branches/1.6.0/utils/astcanary.c (original)
+++ branches/1.6.0/utils/astcanary.c Tue Feb 24 11:53:16 2009
@@ -30,7 +30,7 @@
  * 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.
  *
@@ -57,6 +57,18 @@
  * 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[] =
@@ -77,7 +89,7 @@
 	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 */
@@ -96,7 +108,7 @@
 		sleep(5);
 	}
 
-	/* Never reached */
+	/* Reached if asterisk (our parent process) dies - its chldren are inherited by the init process (pid is 1). */
 	return 0;
 }
 




More information about the asterisk-commits mailing list