Update of /cvsroot/freevo/freevo/src
In directory sc8-pr-cvs1:/tmp/cvs-serv27844

Modified Files:
        childapp.py 
Log Message:
brute force if the app refuces to die

Index: childapp.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/childapp.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** childapp.py 20 Sep 2003 17:32:49 -0000      1.15
--- childapp.py 20 Sep 2003 18:54:04 -0000      1.16
***************
*** 10,13 ****
--- 10,16 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.16  2003/09/20 18:54:04  dischi
+ # brute force if the app refuces to die
+ #
  # Revision 1.15  2003/09/20 17:32:49  dischi
  # less debug
***************
*** 72,75 ****
--- 75,86 ----
              app = app[app.find(' ')+1:]
  
+         if app.find('--prio=') == 0:
+             self.binary = app[app.find(' ')+1:].lstrip()
+         else:
+             self.binary = app.lstrip()
+ 
+         if self.binary.find(' ') > 0:
+             self.binary=self.binary[:self.binary.find(' ')]
+ 
          start_str = '%s %s' % (config.RUNAPP, app)
  
***************
*** 131,138 ****
          # maybe child is dead and only waiting?
          if os.waitpid(self.child.pid, os.WNOHANG)[0] == self.child.pid:
-             self.outfile.close()
-             self.errfile.close()
-             self.infile.close()
              self.child = None
              return
          
--- 142,148 ----
          # maybe child is dead and only waiting?
          if os.waitpid(self.child.pid, os.WNOHANG)[0] == self.child.pid:
              self.child = None
+             if not self.infile.closed:
+                 self.infile.close()
              return
          
***************
*** 156,169 ****
          except OSError:
              pass
!         
!         # this may cause some problems with threads
!         # in the child because not everything died :-(
!         # try:
!         # self.outfile.close()
!         # self.errfile.close()
!         # self.infile.close()
!         # except:
!         #    print 'error closing filehandler'
!         #    pass
          self.child = None
  
--- 166,203 ----
          except OSError:
              pass
! 
!         # now check if the app is really dead. If it is, outfile
!         # should be closed by the reading thread
!         for i in range(5):
!             if self.outfile.closed:
!                 break
!             time.sleep(0.1)
!         else:
!             # Problem: the program had more than one thread, each thread has a
!             # pid. We killed only a part of the program. The filehandles are
!             # still open, the program still lives. If we try to close the infile
!             # now, Freevo will be dead.
!             # Solution: there is no good one, let's try killall on the binary. It's
!             # ugly but it's the _only_ way to stop this nasty app
!             print 'Oops, command refuses to die, try bad hack....'
!             os.system('killall %s' % self.binary)
!             for i in range(20):
!                 if self.outfile.closed:
!                     break
!                 time.sleep(0.1)
!             else:
!                 # still not dead. Puh, something is realy broekn here.
!                 # Try killall -9 as last chance
!                 print 'Try harder to kill the app....'
!                 os.system('killall -9 %s' % self.binary)
!                 for i in range(20):
!                     if self.outfile.closed:
!                         break
!                     time.sleep(0.1)
!                 else:
!                     # Oops...
!                     print 'PANIC'
!             if not self.infile.closed:
!                 self.infile.close()
          self.child = None
  
***************
*** 193,200 ****
          while 1:
  
-             # XXX There should be a C helper app that converts CR to LF.
              data = self.fp.readline(300)
              if not data:
                  _debug_('%s: No data, stopping (pid %s)!' % (self.name, os.getpid()))
                  break
              else:
--- 227,234 ----
          while 1:
  
              data = self.fp.readline(300)
              if not data:
                  _debug_('%s: No data, stopping (pid %s)!' % (self.name, os.getpid()))
+                 self.fp.close()
                  break
              else:
***************
*** 261,265 ****
          if self.mode != 'play':
              return
!         
          if cmd:
              self.manual_stop = True
--- 295,299 ----
          if self.mode != 'play':
              return
! 
          if cmd:
              self.manual_stop = True
***************
*** 276,281 ****
          while self.mode == 'stop':
              time.sleep(0.3)
! 
!         
      def run(self):
          while 1:
--- 310,314 ----
          while self.mode == 'stop':
              time.sleep(0.3)
!                 
      def run(self):
          while 1:




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to