Repository navigation
Closed
Description
Summary
Running pjm watch --daemon on Windows fails immediately with an AttributeError: module 'os' has no attribute 'fork'. The current daemonization implementation relies directly on Unix-specific POSIX APIs (os.fork() and os.setsid()), making background watching unusable on Windows platforms.
Environment
- OS: Windows 11 (x86_64)
- Shell: PowerShell / cmd
- Python Version: 3.10+
Steps to Reproduce
- Open a terminal on a Windows host inside an initialized
projectmemworkspace. - Run
pjm watch --status(verifies the watcher is currently idle). - Attempt to start the watcher in the background:
pjm watch --daemon
Expected Behavior
The watcher process should detach and run in the background, writing its PID to .projectmem/watch.pid and logging file activity to .projectmem/watch.log, regardless of the host operating system.
Actual Behavior
The CLI crashes with the following traceback:
╭───────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────╮
│ C:\Users\...\site-packages\projectmem\cli.py:386 in watch │
│ │
│ 383 │ status: bool = typer.Option(False, "--status", help="Show watcher status."), │
│ 384 │ """Watch file activity in real-time and log churn events (opt-in).""" │
│ ❱ 386 │ watch_command.run(daemon=daemon, stop=stop, status=status) │
│ │
│ C:\Users\...\site-packages\projectmem\commands\watch.py:157 in run │
│ │
│ 156 │ if daemon: │
│ ❱ 157 │ │ _run_as_daemon(root) │
│ 158 │ else: │
│ 159 │ │ _run_foreground(root) │
│ │
│ C:\Users\...\site-packages\projectmem\commands\watch.py:179 in _run_as_daemon │
│ │
│ 176 │ """Fork to background and run watch loop.""" │
│ 177 │ # Fork once and detach │
│ 178 │ try: │
│ ❱ 179 │ │ pid = os.fork() │
│ 180 │ except OSError as e: │
│ 181 │ │ typer.echo(f"\033[31mprojectmem:\033[0m Daemon fork failed: {e}", err=True) │
│ 182 │ │ return │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: module 'os' has no attribute 'fork'
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]AttributeError: module 'os' has no attribute 'fork'` on Windows when running `pjm watch --daemon[/-][+]`AttributeError: module 'os' has no attribute 'fork'` on Windows when running `pjm watch --daemon`[/+]Merge PR #13: cross-platform watch daemon (Windows support)
release: 0.3.2 — Windows watch support, and a doctor that spots a rev…