Watching existing child process PIDs
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 27.2k
- Forks
- 3.9k
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 17
Description
I'm unsure if this is a documentation issue or a feature request.
I have existing code that does the fork (and maybe exec or maybe not) parts of creating a child process, and I wish to use libuv to watch those processes for exit. Can I do this? I couldn't see anything in docs - there doesn't appear to be a "uv_child_t" type that I can give an existing PID to, and all of the ways I can see to create a "uv_process_t" start off by my supplying a new command to be exec'ed, and it does the whole dance for me.
I currently have a very hacky workaround, which involves my watching for SIGCHLD directly, and on receipt of such a signal I try to waitpid() specifically on every child process PID I still have outstanding. While that works in small cases, it doesn't feel like it will scale very well. Anything else would interfere with libuv's own child process reaping.
If this ability does exist in libuv, then I wasn't able to find it in the docs, so perhaps more attention needs to be drawn to it.
Alternatively if not, can this be considered a feature request to add such? Maybe either an alternative to "uv_spawn()" which still uses a uv_process_t, or else a whole new handle type (uv_child_t?) that just wraps a preëxisting process created elsewhere, that libuv will just watch for exit.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the libuv documentation for uv_spawn and uv_process_t, then review the issue's SIGCHLD and waitpid discussion. Determine whether an existing child PID can be monitored through the current API; if not, define the cross-platform behavior and API requirements for such support, including how libuv handles reaping.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100