Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Sep 9, 2025

Summary

Enables users to access and kill child processes immediately without having to await the process result first, addressing issue #20.

The key issue was that process.child.kill('SIGTERM') was not accessible without first awaiting the process, making it impossible to kill long-running processes before they complete.

Changes

  • Add child getter: Provides immediate access to child process for killing
  • Virtual command support: Return proxy object with kill() method that delegates to ProcessRunner
  • Real command support: Auto-start process when child is accessed
  • Internal refactoring: Update references from this.child to this._child for internal use
  • Bug fix: Fix kill() method to properly handle virtual commands

Usage

Both virtual and real commands now support immediate killing:

// Virtual command (uses proxy child)
const proc1 = $`sleep 10`;
proc1.child.kill('SIGTERM'); // ✅ Works immediately

// Real command (auto-starts and provides real child)  
const proc2 = $`/bin/sleep 10`;
proc2.child.kill('SIGTERM'); // ✅ Works immediately

Test plan

  • ✅ Added comprehensive test suite in tests/child-access.test.mjs
  • ✅ All existing tests pass (ctrl-c-basic.test.mjs, $.test.mjs, streaming-interfaces.test.mjs)
  • ✅ Verified both virtual and real commands support killing
  • ✅ Confirmed processes actually terminate with correct exit codes
  • ✅ No breaking changes to existing API

🤖 Generated with Claude Code


Resolves #20

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #20
@konard konard self-assigned this Sep 9, 2025
konard and others added 2 commits September 9, 2025 22:38
This change enables users to access and kill child processes immediately
without having to await the process result first. The implementation
addresses both virtual commands and real child processes.

Key changes:
- Add child getter that provides immediate access to process for killing
- For virtual commands: return proxy object with kill() method that delegates
- For real commands: auto-start process when child is accessed
- Update internal references from this.child to this._child
- Fix kill() method to properly handle virtual commands

The solution allows both patterns to work:
- Virtual: $`sleep 5`.child.kill('SIGTERM')
- Real: $`/bin/sleep 5`.child.kill('SIGTERM')

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

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] The child object should be accessable and it should be possible to be able to kill process using it Fix #20: Enable immediate child process access for killing Sep 9, 2025
@konard konard marked this pull request as ready for review September 9, 2025 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The child object should be accessable and it should be possible to be able to kill process using it

2 participants