Commits

Anonymous committed 9f135b3

Fix so that after a fork() -- on Unix only -- the template gets
recalculated.

  • Participants
  • Parent commits f351c64
  • Branches legacy-trunk

Comments (0)

Files changed (1)

File Lib/tempfile.py

 
 # Function to calculate a prefix of the filename to use
 
+_pid = None
+
 def gettempprefix():
-    global template
-    if template == None:
+    global template, _pid
+    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':
-            template = '@' + `os.getpid()` + '.'
+            _pid = os.getpid()
+            template = '@' + `_pid` + '.'
         elif os.name == 'nt':
             template = '~' + `os.getpid()` + '-'
         elif os.name == 'mac':