summaryrefslogtreecommitdiffstats
path: root/DOCS/man
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-02-16 21:57:17 +0100
committerwm4 <wm4@nowhere>2020-02-16 22:08:48 +0100
commitf2c7c641b38d060a7eea52a92bc0239f1603bffb (patch)
treed6f6df3c7a8325edf6c22d45c846d022f50e57a7 /DOCS/man
parent92fee4ebc4852f023527dc64b28e5b10e4507053 (diff)
downloadmpv-f2c7c641b38d060a7eea52a92bc0239f1603bffb.tar.bz2
mpv-f2c7c641b38d060a7eea52a92bc0239f1603bffb.tar.xz
subprocess: implement proper detached processes on POSIX
The previous method for this sucked: for every launched detached process, it started a thread, which then would leak if the launched process didn't end before the player uninitialized. This was very racy (although I bet the race condition wouldn't trigger in a 100 years), and wasteful (threads aren't a cheap resource). Implement it for POSIX directly. posix_spawn() has no direct support for this, so we need to do it ourselves with fork(). We could probably do it without fork(), and attempt to collect the PID in another thread. But then we'd either have a waiting thread again, or we'd need to do an unsafe waitpid(-1, ...) call. (POSIX process management sucks so badly, how did they even manage this. Hopefully I'm just missing something, but I'm not.) So now we depend on both posix_spawn() _and_ fork(), isn't it fun? Also call setsid(), to essentially detach the child process from the terminal. (Otherwise it can receive various signals from the terminal, which is probably not what you want.) posix_spawn() adds POSIX_SPAWN_SETSID in newer POSIX releases, but we don't want to rely on this yet. The posix_spawnp() call is duplicated, but this is better than somehow trying to unify the code paths. Only somewhat tested, so enjoy the bugs.
Diffstat (limited to 'DOCS/man')
0 files changed, 0 insertions, 0 deletions