Skip to content

AttributeError: module 'os' has no attribute 'fork' on Windows when running pjm watch --daemon #12

Closed

Description

@medium-effort

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

  1. Open a terminal on a Windows host inside an initialized projectmem workspace.
  2. Run pjm watch --status (verifies the watcher is currently idle).
  3. 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'

Activity

  1. changed the title [-]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`[/+] on Sep 6, 2026
  2. added 2 commits that reference this issue on Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions