Trees | Indices | Help |
|
---|
|
1 ############################################################################### 2 # # 3 # Copyright (C) 2004 Edward d'Auvergne # 4 # # 5 # This file is part of the program relax. # 6 # # 7 # relax is free software; you can redistribute it and/or modify # 8 # it under the terms of the GNU General Public License as published by # 9 # the Free Software Foundation; either version 2 of the License, or # 10 # (at your option) any later version. # 11 # # 12 # relax is distributed in the hope that it will be useful, # 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of # 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # 15 # GNU General Public License for more details. # 16 # # 17 # You should have received a copy of the GNU General Public License # 18 # along with relax; if not, write to the Free Software # 19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # 20 # # 21 ############################################################################### 22 23 from os import popen3, system 24 from popen2 import Popen3 25 26 # UNIX only module. 27 try: 28 from os import kill 29 kill_module = 1 30 except ImportError: 31 kill_module = 0 32 33 346837 """Extended Popen3 class.""" 38 39 # Run the init function of the Popen3 class. 40 Popen3.__init__(self, cmd, capturestderr, bufsize)41 4244 """Function for killing the child process.""" 45 46 # Don't do anything if the child process has already finished. 47 if self.poll() != -1: 48 return 49 50 # Kill the child process (or pass silently if the PID no longer exists). 51 if kill_module: 52 try: 53 kill(self.pid, sig) 54 except: 55 pass 56 57 # Kill the relax process spawned by the thread. 58 if hasattr(self, 'relax_pid') and self.relax_pid != None: 59 # Kill command. 60 kill_cmd = 'kill -%s %s' % (sig, self.relax_pid) 61 62 # Remote relax process. 63 if login_cmd: 64 kill_cmd = login_cmd + " \"" + kill_cmd + "\"" 65 66 # Kill relax. 67 stdin, stdout, stderr = popen3(kill_cmd)
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Apr 10 14:04:22 2013 | http://epydoc.sourceforge.net |