Spawn a daemon process (Windows).
(args: Sequence[str])
| 59 | _DETACHED_PROCESS = getattr(subprocess, "DETACHED_PROCESS", 0x00000008) |
| 60 | |
| 61 | def _spawn_daemon(args: Sequence[str]) -> None: |
| 62 | """Spawn a daemon process (Windows).""" |
| 63 | try: |
| 64 | with open(os.devnull, "r+b") as devnull: |
| 65 | popen = subprocess.Popen( |
| 66 | args, # noqa: S603 |
| 67 | creationflags=_DETACHED_PROCESS, |
| 68 | stdin=devnull, |
| 69 | stderr=devnull, |
| 70 | stdout=devnull, |
| 71 | ) |
| 72 | _silence_resource_warning(popen) |
| 73 | except FileNotFoundError as exc: |
| 74 | warnings.warn( |
| 75 | f"Failed to start {args[0]}: is it on your $PATH?\nOriginal exception: {exc}", |
| 76 | RuntimeWarning, |
| 77 | stacklevel=2, |
| 78 | ) |
| 79 | |
| 80 | else: |
| 81 | # On Unix we spawn the daemon process with a double Popen. |