@@ -210,10 +210,11 @@ def fortune(self, irc, msg, args):
210
210
args .append ('-a' )
211
211
args .extend (self .registryValue ('fortune.files' ))
212
212
try :
213
- inst = subprocess .Popen (args , close_fds = True ,
214
- stdout = subprocess .PIPE ,
215
- stderr = subprocess .PIPE ,
216
- stdin = open (os .devnull ))
213
+ with open (os .devnull ) as null :
214
+ inst = subprocess .Popen (args ,
215
+ stdout = subprocess .PIPE ,
216
+ stderr = subprocess .PIPE ,
217
+ stdin = null )
217
218
except OSError as e :
218
219
irc .error (_ ('It seems the configured fortune command was '
219
220
'not available.' ), Raise = True )
@@ -241,10 +242,11 @@ def wtf(self, irc, msg, args, foo, something):
241
242
if wtfCmd :
242
243
something = something .rstrip ('?' )
243
244
try :
244
- inst = subprocess .Popen ([wtfCmd , something ], close_fds = True ,
245
- stdout = subprocess .PIPE ,
246
- stderr = open (os .devnull ),
247
- stdin = open (os .devnull ))
245
+ with open (os .devnull , 'r+' ) as null :
246
+ inst = subprocess .Popen ([wtfCmd , something ],
247
+ stdout = subprocess .PIPE ,
248
+ stderr = null ,
249
+ stdin = null )
248
250
except OSError :
249
251
irc .error (_ ('It seems the configured wtf command was not '
250
252
'available.' ), Raise = True )
@@ -291,9 +293,11 @@ def ping(self, irc, msg, args, optlist, host):
291
293
args .append ('5' )
292
294
args .append (host )
293
295
try :
294
- inst = subprocess .Popen (args , stdout = subprocess .PIPE ,
295
- stderr = subprocess .PIPE ,
296
- stdin = open (os .devnull ))
296
+ with open (os .devnull ) as null :
297
+ inst = subprocess .Popen (args ,
298
+ stdout = subprocess .PIPE ,
299
+ stderr = subprocess .PIPE ,
300
+ stdin = null )
297
301
except OSError as e :
298
302
irc .error ('It seems the configured ping command was '
299
303
'not available (%s).' % e , Raise = True )
@@ -323,10 +327,11 @@ def sysuptime(self, irc, msg, args):
323
327
if uptimeCmd :
324
328
args = [uptimeCmd ]
325
329
try :
326
- inst = subprocess .Popen (args , close_fds = True ,
330
+ with open (os .devnull ) as null :
331
+ inst = subprocess .Popen (args ,
327
332
stdout = subprocess .PIPE ,
328
333
stderr = subprocess .PIPE ,
329
- stdin = open ( os . devnull ) )
334
+ stdin = null )
330
335
except OSError as e :
331
336
irc .error ('It seems the configured uptime command was '
332
337
'not available.' , Raise = True )
@@ -351,10 +356,11 @@ def sysuname(self, irc, msg, args):
351
356
if unameCmd :
352
357
args = [unameCmd , '-a' ]
353
358
try :
354
- inst = subprocess .Popen (args , close_fds = True ,
355
- stdout = subprocess .PIPE ,
356
- stderr = subprocess .PIPE ,
357
- stdin = open (os .devnull ))
359
+ with open (os .devnull ) as null :
360
+ inst = subprocess .Popen (args ,
361
+ stdout = subprocess .PIPE ,
362
+ stderr = subprocess .PIPE ,
363
+ stdin = null )
358
364
except OSError as e :
359
365
irc .error ('It seems the configured uptime command was '
360
366
'not available.' , Raise = True )
@@ -381,9 +387,10 @@ def call(self, irc, msg, args, text):
381
387
"""
382
388
args = shlex .split (text )
383
389
try :
384
- inst = subprocess .Popen (args , stdout = subprocess .PIPE ,
385
- stderr = subprocess .PIPE ,
386
- stdin = open (os .devnull ))
390
+ with open (os .devnull ) as null :
391
+ inst = subprocess .Popen (args , stdout = subprocess .PIPE ,
392
+ stderr = subprocess .PIPE ,
393
+ stdin = null )
387
394
except OSError as e :
388
395
irc .error ('It seems the requested command was '
389
396
'not available (%s).' % e , Raise = True )
0 commit comments