Mercurial > hg
comparison mercurial/cmdutil.py @ 10237:2f7a38f336f4
serve: add and use portable spawnvp replacement
There is no standard python command to really detach a process under Windows.
Instead we use the low level API wrapped by subprocess module with all
necessary options to avoid any kind of context inheritance. Unfortunately, this
version still opens a new window for the child process.
The following have been tried:
- os.spawnv(os.P_NOWAIT): works but the child process is killed when parent
console terminates.
- os.spawnv(os.P_DETACH): works on python25, hang on python26 when writing to
the hgweb output socket.
- subprocess.CreateProcess() hack without shell mode: similar to
os.spawnv(os.P_DETACH).
Fix 1/3 for issue421
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Fri, 10 Apr 2009 21:20:25 +0200 |
parents | 48653dea23dd |
children | e22695b4472f |
comparison
equal
deleted
inserted
replaced
10236:49a8625b8cac | 10237:2f7a38f336f4 |
---|---|
578 del runargs[i] | 578 del runargs[i] |
579 break | 579 break |
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: |
588 return parentfn(pid) | 587 return parentfn(pid) |
589 else: | 588 else: |