<feed xmlns='http://www.w3.org/2005/Atom'>
<title>demon/tests/cli.rs, branch fix-process-daemonization</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='http://git.d464.sh/demon/'/>
<entry>
<title>Fix critical process daemonization issue by replacing std::mem::forget with proper background thread management</title>
<updated>2025-06-26T15:23:04+00:00</updated>
<author>
<name>diogo464</name>
<email>diogo464@d464.sh</email>
</author>
<published>2025-06-26T15:23:04+00:00</published>
<link rel='alternate' type='text/html' href='http://git.d464.sh/demon/commit/?id=53382d0ebf5f08edbe163981c6bfe2f286bfe5d1'/>
<id>53382d0ebf5f08edbe163981c6bfe2f286bfe5d1</id>
<content type='text'>
PROBLEM:
The previous implementation used std::mem::forget(child) to detach processes,
which caused several critical issues:
- Prevented Child destructor from running, leading to resource leaks
- Could result in zombie processes under certain conditions
- Violated Rust best practices for resource management
- No proper cleanup of OS handles and process resources

SOLUTION:
Replaced std::mem::forget(child) with a background thread approach:
- Spawn child process in background thread that owns the Child struct
- When thread completes, Child's Drop implementation runs automatically
- Ensures proper resource cleanup while maintaining process detachment
- Process becomes child of init (PID 1) which handles reaping
- Follows Rust idioms for resource management

VERIFICATION:
- Added test that verifies proper resource management
- All existing functionality preserved
- No breaking changes to CLI interface
- Improved system resource handling

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude &lt;noreply@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
PROBLEM:
The previous implementation used std::mem::forget(child) to detach processes,
which caused several critical issues:
- Prevented Child destructor from running, leading to resource leaks
- Could result in zombie processes under certain conditions
- Violated Rust best practices for resource management
- No proper cleanup of OS handles and process resources

SOLUTION:
Replaced std::mem::forget(child) with a background thread approach:
- Spawn child process in background thread that owns the Child struct
- When thread completes, Child's Drop implementation runs automatically
- Ensures proper resource cleanup while maintaining process detachment
- Process becomes child of init (PID 1) which handles reaping
- Follows Rust idioms for resource management

VERIFICATION:
- Added test that verifies proper resource management
- All existing functionality preserved
- No breaking changes to CLI interface
- Improved system resource handling

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude &lt;noreply@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix typo in README.md: change 'demon tail =f' to 'demon tail -f'</title>
<updated>2025-06-26T15:14:29+00:00</updated>
<author>
<name>diogo464</name>
<email>diogo464@d464.sh</email>
</author>
<published>2025-06-26T15:14:29+00:00</published>
<link rel='alternate' type='text/html' href='http://git.d464.sh/demon/commit/?id=c6afda3f8c40cb8f8a27b6e714f9eb24ece26f90'/>
<id>c6afda3f8c40cb8f8a27b6e714f9eb24ece26f90</id>
<content type='text'>
The README.md file contained an incorrect command syntax on line 102
showing 'demon tail =f web-server --stderr' instead of the correct
'demon tail -f web-server --stderr'. This fix corrects the typo
to show the proper -f flag syntax.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude &lt;noreply@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The README.md file contained an incorrect command syntax on line 102
showing 'demon tail =f web-server --stderr' instead of the correct
'demon tail -f web-server --stderr'. This fix corrects the typo
to show the proper -f flag syntax.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude &lt;noreply@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix all tests and add cargo test to pre-commit hook</title>
<updated>2025-06-23T10:03:22+00:00</updated>
<author>
<name>diogo464</name>
<email>diogo464@d464.sh</email>
</author>
<published>2025-06-23T10:03:22+00:00</published>
<link rel='alternate' type='text/html' href='http://git.d464.sh/demon/commit/?id=b5b83ca1a71cfd756c89a65ed8902597b4b741f6'/>
<id>b5b83ca1a71cfd756c89a65ed8902597b4b741f6</id>
<content type='text'>
- Fixed all 19 failing tests by replacing --root-dir flag with DEMON_ROOT_DIR environment variable
- All 28 tests now pass consistently
- Added cargo test to pre-commit hook for comprehensive quality checks
- Pre-commit hook now runs: cargo fmt, cargo clippy, and cargo test

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude &lt;noreply@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- Fixed all 19 failing tests by replacing --root-dir flag with DEMON_ROOT_DIR environment variable
- All 28 tests now pass consistently
- Added cargo test to pre-commit hook for comprehensive quality checks
- Pre-commit hook now runs: cargo fmt, cargo clippy, and cargo test

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude &lt;noreply@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Add pre-commit hook for cargo fmt and apply formatting</title>
<updated>2025-06-23T09:36:24+00:00</updated>
<author>
<name>diogo464</name>
<email>diogo464@d464.sh</email>
</author>
<published>2025-06-23T09:36:24+00:00</published>
<link rel='alternate' type='text/html' href='http://git.d464.sh/demon/commit/?id=b257b2259dc3ad7d0aa4df86ef241b66932204a9'/>
<id>b257b2259dc3ad7d0aa4df86ef241b66932204a9</id>
<content type='text'>
- Created pre-commit hook that runs cargo fmt --check
- If formatting issues found, runs cargo fmt and asks for re-commit
- Applied cargo fmt to fix existing formatting issues

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude &lt;noreply@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- Created pre-commit hook that runs cargo fmt --check
- If formatting issues found, runs cargo fmt and asks for re-commit
- Applied cargo fmt to fix existing formatting issues

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude &lt;noreply@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Change default root directory to use .demon subdirectory</title>
<updated>2025-06-22T21:15:14+00:00</updated>
<author>
<name>diogo464</name>
<email>diogo464@d464.sh</email>
</author>
<published>2025-06-22T21:15:14+00:00</published>
<link rel='alternate' type='text/html' href='http://git.d464.sh/demon/commit/?id=ea62efa29f99791030c6e486955580051ced3e29'/>
<id>ea62efa29f99791030c6e486955580051ced3e29</id>
<content type='text'>
- Modified find_git_root() to create and return &lt;git_root&gt;/.demon instead of &lt;git_root&gt;
- Auto-creates .demon directory if it doesn't exist
- Added proper error handling for edge cases (file vs directory conflicts, permissions)
- Maintains backward compatibility with explicit --root-dir flag
- Added comprehensive test to verify new default behavior
- Fixed test argument ordering for test_list_empty

Files are now organized as:
- Before: /project/daemon.pid, /project/daemon.stdout, /project/daemon.stderr
- After: /project/.demon/daemon.pid, /project/.demon/daemon.stdout, /project/.demon/daemon.stderr

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude &lt;noreply@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- Modified find_git_root() to create and return &lt;git_root&gt;/.demon instead of &lt;git_root&gt;
- Auto-creates .demon directory if it doesn't exist
- Added proper error handling for edge cases (file vs directory conflicts, permissions)
- Maintains backward compatibility with explicit --root-dir flag
- Added comprehensive test to verify new default behavior
- Fixed test argument ordering for test_list_empty

Files are now organized as:
- Before: /project/daemon.pid, /project/daemon.stdout, /project/daemon.stderr
- After: /project/.demon/daemon.pid, /project/.demon/daemon.stdout, /project/.demon/daemon.stderr

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude &lt;noreply@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Add comprehensive integration tests for clean command behavior</title>
<updated>2025-06-22T20:52:29+00:00</updated>
<author>
<name>diogo464</name>
<email>diogo464@d464.sh</email>
</author>
<published>2025-06-22T20:52:29+00:00</published>
<link rel='alternate' type='text/html' href='http://git.d464.sh/demon/commit/?id=2b4bca30e88f99b803911dbbc9764d7e9a447d31'/>
<id>2b4bca30e88f99b803911dbbc9764d7e9a447d31</id>
<content type='text'>
- Enhanced test_clean_with_orphans with explicit verification steps
- Added test_clean_removes_stdout_stderr_files to explicitly verify that clean removes all three file types (.pid, .stdout, .stderr)
- Fixed argument ordering in tests (--root-dir should come after subcommand)
- Tests confirm that clean command correctly removes stdout and stderr files, not just pid files

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude &lt;noreply@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- Enhanced test_clean_with_orphans with explicit verification steps
- Added test_clean_removes_stdout_stderr_files to explicitly verify that clean removes all three file types (.pid, .stdout, .stderr)
- Fixed argument ordering in tests (--root-dir should come after subcommand)
- Tests confirm that clean command correctly removes stdout and stderr files, not just pid files

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude &lt;noreply@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Add configurable root directory for daemon files with git root discovery</title>
<updated>2025-06-19T16:11:09+00:00</updated>
<author>
<name>diogo464</name>
<email>diogo464@d464.sh</email>
</author>
<published>2025-06-19T16:11:09+00:00</published>
<link rel='alternate' type='text/html' href='http://git.d464.sh/demon/commit/?id=a365f12a6c6e7775a5bd3c6177050b74826c608c'/>
<id>a365f12a6c6e7775a5bd3c6177050b74826c608c</id>
<content type='text'>
Implement --root-dir global option to specify where daemon files (PID, stdout, stderr) are created. When not specified, automatically searches upward for git repository root. This addresses the issue of daemon files being scattered across various working directories.

Key features:
- Global --root-dir option available on all commands
- Automatic git root discovery when --root-dir not specified
- Proper error handling for invalid directories
- Updated all file operations to use configurable root directory
- Optimized HashMap usage with PathBuf for better performance
- Fixed ID extraction to show daemon names instead of full paths
- Updated tests to work with new directory structure

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude &lt;noreply@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Implement --root-dir global option to specify where daemon files (PID, stdout, stderr) are created. When not specified, automatically searches upward for git repository root. This addresses the issue of daemon files being scattered across various working directories.

Key features:
- Global --root-dir option available on all commands
- Automatic git root discovery when --root-dir not specified
- Proper error handling for invalid directories
- Updated all file operations to use configurable root directory
- Optimized HashMap usage with PathBuf for better performance
- Fixed ID extraction to show daemon names instead of full paths
- Updated tests to work with new directory structure

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude &lt;noreply@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Add wait subcommand for blocking until process termination</title>
<updated>2025-06-19T09:03:56+00:00</updated>
<author>
<name>diogo464</name>
<email>diogo464@d464.sh</email>
</author>
<published>2025-06-19T09:03:56+00:00</published>
<link rel='alternate' type='text/html' href='http://git.d464.sh/demon/commit/?id=5101d9c410a7c901ea20636d2a4e56b3282a1c14'/>
<id>5101d9c410a7c901ea20636d2a4e56b3282a1c14</id>
<content type='text'>
Implements a new 'wait' subcommand that blocks until a specified daemon process terminates, with configurable timeout and polling interval.

Features:
- Default 30-second timeout, configurable with --timeout flag
- Infinite wait with --timeout 0
- Configurable polling interval with --interval flag (default 1 second)
- Quiet operation - only shows errors on failure
- Preserves PID files (doesn't clean up)
- Exit codes: 0 for success, 1 for failure

Usage examples:
- demon wait my-process                    # Wait 30s
- demon wait my-process --timeout 0        # Wait indefinitely
- demon wait my-process --timeout 60 --interval 2  # Custom timeout/interval

Added comprehensive test suite covering:
- Non-existent processes
- Already terminated processes
- Normal process termination
- Timeout scenarios
- Infinite timeout behavior
- Custom polling intervals

Updated documentation:
- README.md with wait command reference and usage examples
- LLM guide with detailed wait command documentation
- Integration examples for development workflows

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude &lt;noreply@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Implements a new 'wait' subcommand that blocks until a specified daemon process terminates, with configurable timeout and polling interval.

Features:
- Default 30-second timeout, configurable with --timeout flag
- Infinite wait with --timeout 0
- Configurable polling interval with --interval flag (default 1 second)
- Quiet operation - only shows errors on failure
- Preserves PID files (doesn't clean up)
- Exit codes: 0 for success, 1 for failure

Usage examples:
- demon wait my-process                    # Wait 30s
- demon wait my-process --timeout 0        # Wait indefinitely
- demon wait my-process --timeout 60 --interval 2  # Custom timeout/interval

Added comprehensive test suite covering:
- Non-existent processes
- Already terminated processes
- Normal process termination
- Timeout scenarios
- Infinite timeout behavior
- Custom polling intervals

Updated documentation:
- README.md with wait command reference and usage examples
- LLM guide with detailed wait command documentation
- Integration examples for development workflows

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude &lt;noreply@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Make --id a positional argument for improved CLI usability</title>
<updated>2025-06-19T08:46:52+00:00</updated>
<author>
<name>diogo464</name>
<email>diogo464@d464.sh</email>
</author>
<published>2025-06-19T08:46:52+00:00</published>
<link rel='alternate' type='text/html' href='http://git.d464.sh/demon/commit/?id=6a4e906586a043dff295be532d653f4635974502'/>
<id>6a4e906586a043dff295be532d653f4635974502</id>
<content type='text'>
- Remove --id flags from all command argument structures
- Update RunArgs, StopArgs, TailArgs, CatArgs, StatusArgs to use positional ID
- Update all integration tests to use new positional argument syntax
- Update comprehensive LLM guide documentation with new command syntax
- Maintain -- separator support for complex commands
- More natural CLI interface: 'demon run web-server python -m http.server 8080'
- Consistent with common tools like docker, systemctl, git
- Breaking change but improves usability significantly
- All tests pass with new CLI format

Examples of new syntax:
- demon run web-server python -m http.server 8080
- demon stop web-server
- demon status web-server
- demon tail web-server --stdout
- demon cat web-server

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude &lt;noreply@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- Remove --id flags from all command argument structures
- Update RunArgs, StopArgs, TailArgs, CatArgs, StatusArgs to use positional ID
- Update all integration tests to use new positional argument syntax
- Update comprehensive LLM guide documentation with new command syntax
- Maintain -- separator support for complex commands
- More natural CLI interface: 'demon run web-server python -m http.server 8080'
- Consistent with common tools like docker, systemctl, git
- Breaking change but improves usability significantly
- All tests pass with new CLI format

Examples of new syntax:
- demon run web-server python -m http.server 8080
- demon stop web-server
- demon status web-server
- demon tail web-server --stdout
- demon cat web-server

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude &lt;noreply@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Implement PidFileReadError enum for better error handling</title>
<updated>2025-06-19T08:40:05+00:00</updated>
<author>
<name>diogo464</name>
<email>diogo464@d464.sh</email>
</author>
<published>2025-06-19T08:40:05+00:00</published>
<link rel='alternate' type='text/html' href='http://git.d464.sh/demon/commit/?id=03793fad36480273ebd702e80f41f4baf513647c'/>
<id>03793fad36480273ebd702e80f41f4baf513647c</id>
<content type='text'>
- Add PidFileReadError enum with FileNotFound, FileInvalid, and IoError variants
- Implement Display and Error traits for proper error handling
- Update PidFile::read_from_file() to return Result&lt;PidFile, PidFileReadError&gt;
- Update all call sites to handle specific error types:
  - is_process_running(): Handle FileNotFound/FileInvalid as "not running"
  - stop_daemon(): Handle FileNotFound as "not running", FileInvalid as cleanup needed
  - list_daemons(): Handle FileInvalid with specific error messages
  - status_daemon(): Handle FileNotFound as "NOT FOUND", FileInvalid as detailed error
  - clean_orphaned_files(): Handle FileInvalid as cleanup candidate
- Remove redundant Path::exists() checks (error type provides this info)
- Fix test timing issue by adding sleep in test_run_creates_files
- More idiomatic Rust error handling with specific error types

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude &lt;noreply@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- Add PidFileReadError enum with FileNotFound, FileInvalid, and IoError variants
- Implement Display and Error traits for proper error handling
- Update PidFile::read_from_file() to return Result&lt;PidFile, PidFileReadError&gt;
- Update all call sites to handle specific error types:
  - is_process_running(): Handle FileNotFound/FileInvalid as "not running"
  - stop_daemon(): Handle FileNotFound as "not running", FileInvalid as cleanup needed
  - list_daemons(): Handle FileInvalid with specific error messages
  - status_daemon(): Handle FileNotFound as "NOT FOUND", FileInvalid as detailed error
  - clean_orphaned_files(): Handle FileInvalid as cleanup candidate
- Remove redundant Path::exists() checks (error type provides this info)
- Fix test timing issue by adding sleep in test_run_creates_files
- More idiomatic Rust error handling with specific error types

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude &lt;noreply@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
