Show More
@@ -580,8 +580,7 b' def service(opts, parentfn=None, initfn=' | |||||
580 | elif runargs[i].startswith('--cwd'): |
|
580 | elif runargs[i].startswith('--cwd'): | |
581 | del runargs[i:i+2] |
|
581 | del runargs[i:i+2] | |
582 | break |
|
582 | break | |
583 | pid = os.spawnvp(os.P_NOWAIT | getattr(os, 'P_DETACH', 0), |
|
583 | pid = util.spawndetached(runargs) | |
584 | runargs[0], runargs) |
|
|||
585 | os.close(wfd) |
|
584 | os.close(wfd) | |
586 | os.read(rfd, 1) |
|
585 | os.read(rfd, 1) | |
587 | if parentfn: |
|
586 | if parentfn: |
@@ -257,3 +257,8 b' def groupname(gid=None):' | |||||
257 | return grp.getgrgid(gid)[0] |
|
257 | return grp.getgrgid(gid)[0] | |
258 | except KeyError: |
|
258 | except KeyError: | |
259 | return str(gid) |
|
259 | return str(gid) | |
|
260 | ||||
|
261 | def spawndetached(args): | |||
|
262 | return os.spawnvp(os.P_NOWAIT | getattr(os, 'P_DETACH', 0), | |||
|
263 | args[0], args) | |||
|
264 |
@@ -7,7 +7,7 b'' | |||||
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 | |
@@ -321,6 +321,37 b' def rename(src, dst):' | |||||
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 * |
General Comments 0
You need to be logged in to leave comments.
Login now