equal
deleted
inserted
replaced
5 # This software may be used and distributed according to the terms of the |
5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2, incorporated herein by reference. |
6 # GNU General Public License version 2, incorporated herein by reference. |
7 |
7 |
8 from i18n import _ |
8 from i18n import _ |
9 import osutil, error |
9 import osutil, error |
10 import errno, msvcrt, os, re, sys, random |
10 import errno, msvcrt, os, re, sys, random, subprocess |
11 |
11 |
12 nulldev = 'NUL:' |
12 nulldev = 'NUL:' |
13 umask = 002 |
13 umask = 002 |
14 |
14 |
15 # wrap osutil.posixfile to provide friendlier exceptions |
15 # wrap osutil.posixfile to provide friendlier exceptions |
319 # aborting at this point may leave serious inconsistencies. |
319 # aborting at this point may leave serious inconsistencies. |
320 # Ideally, we would notify the user here. |
320 # Ideally, we would notify the user here. |
321 pass |
321 pass |
322 os.rename(src, dst) |
322 os.rename(src, dst) |
323 |
323 |
|
324 def spawndetached(args): |
|
325 # No standard library function really spawns a fully detached |
|
326 # process under win32 because they allocate pipes or other objects |
|
327 # to handle standard streams communications. Passing these objects |
|
328 # to the child process requires handle inheritance to be enabled |
|
329 # which makes really detached processes impossible. |
|
330 class STARTUPINFO: |
|
331 dwFlags = subprocess.STARTF_USESHOWWINDOW |
|
332 hStdInput = None |
|
333 hStdOutput = None |
|
334 hStdError = None |
|
335 wShowWindow = subprocess.SW_HIDE |
|
336 |
|
337 args = subprocess.list2cmdline(args) |
|
338 # Not running the command in shell mode makes python26 hang when |
|
339 # writing to hgweb output socket. |
|
340 comspec = os.environ.get("COMSPEC", "cmd.exe") |
|
341 args = comspec + " /c " + args |
|
342 hp, ht, pid, tid = subprocess.CreateProcess( |
|
343 None, args, |
|
344 # no special security |
|
345 None, None, |
|
346 # Do not inherit handles |
|
347 0, |
|
348 # DETACHED_PROCESS |
|
349 0x00000008, |
|
350 os.environ, |
|
351 os.getcwd(), |
|
352 STARTUPINFO()) |
|
353 return pid |
|
354 |
324 try: |
355 try: |
325 # override functions with win32 versions if possible |
356 # override functions with win32 versions if possible |
326 from win32 import * |
357 from win32 import * |
327 except ImportError: |
358 except ImportError: |
328 pass |
359 pass |