Home | Trees | Indices | Help |
|
---|
|
1 # Copyright (C) 2010 Peter Couvares 2 # 3 # This program is free software; you can redistribute it and/or modify it 4 # under the terms of the GNU General Public License as published by the 5 # Free Software Foundation; either version 2 of the License, or (at your 6 # option) any later version. 7 # 8 # This program is distributed in the hope that it will be useful, but 9 # WITHOUT ANY WARRANTY; without even the implied warranty of 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 11 # Public License for more details. 12 # 13 # You should have received a copy of the GNU General Public License along 14 # with this program; if not, write to the Free Software Foundation, Inc., 15 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 17 18 import os 19 import errno 20 21 22 """ 23 Check for pid existence efficiently and reliably. (Using the null 24 signal is faster and more unix-portable than looking in /proc). 25 26 Inspired by Larz Wirzenius 27 <http://stackoverflow.com/questions/1005972> 28 """30 """ Returns true if the given pid exists, false otherwise. """ 31 try: 32 # signal 0 is harmless and can be safely used to probe pid existence 33 # faster and more unix-portable than looking in /proc 34 os.kill(pid, 0) 35 except OSError as e: 36 # "permission denied" proves existence; otherwise, no such pid 37 return e.errno == errno.EPERM 38 else: 39 return True40 41 42 """ 43 Performs the equivalent of "mkdir -p", creating any intermediate 44 directories needed to create the leaf directory -- but unlike 45 os.makedirs(), produces no error if the path already exists. 46 47 Inspired by Christos Georgiou 48 <http://stackoverflow.com/questions/600268/mkdir-p-functionality-in-python> 49 """ 58
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue Dec 12 00:34:22 2017 | http://epydoc.sourceforge.net |