Wondering if anyone would be interested in me implementing something like this?
opened 07:55AM - 29 Jul 24 UTC
kind:feature
status:discussion
topic:stdlib:system
## Discussion
- What aspect of the language would you like to see improved?
…
Process.run to have an option to kill the child if the primary process exits
- What are the reasons?
This simplifies cleaning up worker processes on application exit and provides a method to ensure processes are cleaned up if a process crashes or is forcefully killed
- Include practical examples to illustrate your points.
Worker processes in web applications
I personally have processes that launch ffmpeg for certain tasks and find it challenging to ensure they are always cleaned up
- Optionally add one (or more) proposals to improve the current situation.
`Linux` has the prctl system call with the PR_SET_PDEATHSIG option on linux would do the job (fork -> prctl call -> replace with child process)
`BSD` has procctl with PROC_PDEATHSIG_CTL
`Windows` has [CreateJobObject](https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createjobobjecta) to assign workers to a pool which will be cleaned up on exit
TLDR: launched sub-processes that are automatically killed by the OS if your application exits for any reason (seg fault / crashes, force killed or exits gracefully)
Xen
July 31, 2024, 7:30pm
2
Sound interesting. Might solve my final problem on Fix up geckodriver by xendk · Pull Request #44 · watzon/marionette · GitHub
I could live with a shard though.
Would be interesting to see how/if other languages implement this.
looks like python has a function: preexec_fn
You've got a python process that runs another process and waits for it to finish.
Maybe it's some ffmpeg process or something.
Everything is great until, one day, you notice that you've got dangling ffmpeg processes.
That makes it achievable - not sure it would work on windows though
Also glad to see I’m not the only one with dangling ffmpeg processes