Changeset 65230 in vbox for trunk/src/VBox/ValidationKit/testdriver/base.py
- Timestamp:
- Jan 10, 2017 4:07:42 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testdriver/base.py
r65209 r65230 178 178 return sName; 179 179 180 def processInterrupt(uPid): 180 def __processSudoKill(uPid, iSignal, fSudo): 181 """ 182 Does the sudo kill -signal pid thing if fSudo is true, else uses os.kill. 183 """ 184 try: 185 if fSudo: 186 return utils.sudoProcessCall(['/bin/kill', '-%s' % (iSignal,), str(uPid)]) == 0; 187 os.kill(uPid, iSignal); 188 return True; 189 except: 190 reporter.logXcpt('uPid=%s' % (uPid,)); 191 return False; 192 193 def processInterrupt(uPid, fSudo = False): 181 194 """ 182 195 Sends a SIGINT or equivalent to interrupt the specified process. … … 189 202 fRc = winbase.processInterrupt(uPid) 190 203 else: 191 try: 192 os.kill(uPid, signal.SIGINT); 193 fRc = True; 194 except: 195 reporter.logXcpt('uPid=%s' % (uPid,)); 196 fRc = False; 204 fRc = __processSudoKill(uPid, signal.SIGINT, fSudo); 197 205 return fRc; 198 206 199 def sendUserSignal1(uPid ):207 def sendUserSignal1(uPid, fSudo = False): 200 208 """ 201 209 Sends a SIGUSR1 or equivalent to nudge the process into shutting down … … 209 217 fRc = False; 210 218 else: 211 try: 212 os.kill(uPid, signal.SIGUSR1); # pylint: disable=E1101 213 fRc = True; 214 except: 215 reporter.logXcpt('uPid=%s' % (uPid,)); 216 fRc = False; 219 fRc = __processSudoKill(uPid, signal.SIGUSR1, fSudo); # pylint: disable=E1101 217 220 return fRc; 218 221 219 def processTerminate(uPid ):222 def processTerminate(uPid, fSudo = False): 220 223 """ 221 224 Terminates the process in a nice manner (SIGTERM or equivalent). … … 226 229 fRc = winbase.processTerminate(uPid); 227 230 else: 228 try: 229 os.kill(uPid, signal.SIGTERM); 230 fRc = True; 231 except: 232 reporter.logXcpt('uPid=%s' % (uPid,)); 231 fRc = __processSudoKill(uPid, signal.SIGTERM, fSudo); 233 232 return fRc; 234 233 235 def processKill(uPid ):234 def processKill(uPid, fSudo = False): 236 235 """ 237 236 Terminates the process with extreme prejudice (SIGKILL). … … 242 241 fRc = winbase.processKill(uPid); 243 242 else: 244 try: 245 os.kill(uPid, signal.SIGKILL); # pylint: disable=E1101 246 fRc = True; 247 except: 248 reporter.logXcpt('uPid=%s' % (uPid,)); 243 fRc = __processSudoKill(uPid, signal.SIGKILL, fSudo); # pylint: disable=E1101 249 244 return fRc; 250 245 … … 1536 1531 afnMethods = [ sendUserSignal1, processInterrupt, processTerminate, processKill ]; 1537 1532 for fnMethod in afnMethods: 1538 ## @todo Handle SUDO processes.1539 1533 for iPid in dPids: 1540 fnMethod(iPid );1534 fnMethod(iPid, fSudo = dPids[iPid][1]); 1541 1535 1542 1536 for i in range(10):
Note:
See TracChangeset
for help on using the changeset viewer.