mirror of https://github.com/python/cpython.git
Fix so that after a fork() -- on Unix only -- the template gets
recalculated.
This commit is contained in:
parent
d3a6a14330
commit
b0e5718643
|
@ -60,11 +60,17 @@ def gettempdir():
|
||||||
|
|
||||||
# Function to calculate a prefix of the filename to use
|
# Function to calculate a prefix of the filename to use
|
||||||
|
|
||||||
|
_pid = None
|
||||||
|
|
||||||
def gettempprefix():
|
def gettempprefix():
|
||||||
global template
|
global template, _pid
|
||||||
if template == None:
|
if os.name == 'posix' and _pid and _pid != os.getpid():
|
||||||
|
# Our pid changed; we must have forked -- zap the template
|
||||||
|
template = None
|
||||||
|
if template is None:
|
||||||
if os.name == 'posix':
|
if os.name == 'posix':
|
||||||
template = '@' + `os.getpid()` + '.'
|
_pid = os.getpid()
|
||||||
|
template = '@' + `_pid` + '.'
|
||||||
elif os.name == 'nt':
|
elif os.name == 'nt':
|
||||||
template = '~' + `os.getpid()` + '-'
|
template = '~' + `os.getpid()` + '-'
|
||||||
elif os.name == 'mac':
|
elif os.name == 'mac':
|
||||||
|
|
Loading…
Reference in New Issue