*** C:/web2py/gluon/newcron.py.orig	Mon Mar 04 04:26:05 2013
--- C:/web2py/gluon/newcron.py	Wed Mar 06 13:48:52 2013
***************
*** 18,31 ****
--- 18,32 ----
  import portalocker
  import fileutils
  import cPickle
  from settings import global_settings
  
  logger = logging.getLogger("web2py.cron")
  _cron_stopping = False
+ _cron_subprocs = []
  
  
  def absolute_path_link(path):
      """
      Return an absolute path for the destination of a symlink
  
      """
***************
*** 38,52 ****
      return link
  
  
  def stopcron():
      "graceful shutdown of cron"
      global _cron_stopping
      _cron_stopping = True
! 
  
  class extcron(threading.Thread):
  
      def __init__(self, applications_parent, apps=None):
          threading.Thread.__init__(self)
          self.setDaemon(False)
          self.path = applications_parent
--- 39,54 ----
      return link
  
  
  def stopcron():
      "graceful shutdown of cron"
      global _cron_stopping
      _cron_stopping = True
!     for subproc in _cron_subprocs:
!         subproc.terminate()
  
  class extcron(threading.Thread):
  
      def __init__(self, applications_parent, apps=None):
          threading.Thread.__init__(self)
          self.setDaemon(False)
          self.path = applications_parent
***************
*** 228,250 ****
--- 230,254 ----
          if platform.system() == 'Windows':
              shell = False
          self.cmd = cmd
          self.shell = shell
  
      def run(self):
          import subprocess
+         global _cron_subprocs
          if isinstance(self.cmd, (list, tuple)):
              cmd = self.cmd
          else:
              cmd = self.cmd.split()
          proc = subprocess.Popen(cmd,
                                  stdin=subprocess.PIPE,
                                  stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE,
                                  shell=self.shell)
+         _cron_subprocs.append(proc)
          (stdoutdata, stderrdata) = proc.communicate()
          if proc.returncode != 0:
              logger.warning(
                  'WEB2PY CRON Call returned code %s:\n%s' %
                  (proc.returncode, stdoutdata + stderrdata))
          else:
              logger.debug('WEB2PY CRON Call returned success:\n%s'
