mpv/osdep
wm4 f2c7c641b3 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.
2020-02-16 22:08:48 +01:00
..
android android: posix_spawn(p) replacement 2017-09-22 09:24:19 +02:00
macos mac: report playback state to the MediaPlayer Command Center 2020-01-26 12:09:55 +01:00
win32 win32: fix massive memory corruption (take 2) 2017-08-21 18:42:04 +02:00
atomic.h atomic: add mp_atomic_uint64 2019-11-29 12:14:43 +01:00
compiler.h osdep: add portable C11-like alignof() macro 2018-05-24 19:56:35 +02:00
endian.h
getpid.h lua+js: Implement utils.getpid() 2018-02-13 20:16:01 -08:00
glob-win.c
io.c io: remove Windows tmpfile() emulation 2019-09-19 20:37:05 +02:00
io.h player: Optionally validate st_mtime when restoring playback state 2019-11-20 15:11:33 +01:00
macOS_swift_bridge.h mac: replace old event tap for media key support with MediaPlayer 2019-12-15 20:07:31 +01:00
macosx_application.h cocoa-cb: add support for forcing the dedicated GPU for rendering 2020-01-26 12:12:22 +01:00
macosx_application.m mac: remove stdout and stderr redirect for logging 2020-02-08 10:55:07 +01:00
macosx_application_objc.h mac: replace old event tap for media key support with MediaPlayer 2019-12-15 20:07:31 +01:00
macosx_compat.h mac: add missing semicolon to macosx_compat.h 2019-01-26 20:44:36 +01:00
macosx_events.h mac: remove Apple Remote support 2019-12-15 20:07:31 +01:00
macosx_events.m mac: replace old event tap for media key support with MediaPlayer 2019-12-15 20:07:31 +01:00
macosx_events_objc.h mac: replace old event tap for media key support with MediaPlayer 2019-12-15 20:07:31 +01:00
macosx_menubar.h osx: move menu bar creation into its own file 2017-08-18 19:20:41 +02:00
macosx_menubar.m mac: activate logging when started from the bundle 2020-02-08 10:55:07 +01:00
macosx_menubar_objc.h osx: refactor menu bar creation 2017-08-18 19:20:41 +02:00
macosx_touchbar.h
macosx_touchbar.m
macosx_versions.h
main-fn-cocoa.c
main-fn-unix.c
main-fn-win.c win32: remove -municode from mpv binary 2019-09-19 20:37:05 +02:00
main-fn.h
mpv.exe.manifest
mpv.rc mpv.rc: readd actual version info 2018-01-01 21:44:01 +00:00
path-macosx.m osx: fix bundle on macOS High Sierra (10.13) 2017-10-03 11:30:56 +02:00
path-unix.c
path-uwp.c
path-win.c
path.h
polldev.c osdep: add poll shim for macOS 2017-12-09 21:11:46 +02:00
polldev.h osdep: add poll shim for macOS 2017-12-09 21:11:46 +02:00
posix-spawn.h osdep: make use of HAVE_ANDROID 2018-08-20 17:16:22 +02:00
semaphore.h
semaphore_osx.c
strnlen.h osdep: make use of HAVE_ANDROID 2018-08-20 17:16:22 +02:00
subprocess-dummy.c
subprocess-posix.c subprocess: implement proper detached processes on POSIX 2020-02-16 22:08:48 +01:00
subprocess-win.c misc: move mp_cancel from stream.c to thread_tools.c 2018-05-24 19:56:35 +02:00
subprocess.c subprocess: implement proper detached processes on POSIX 2020-02-16 22:08:48 +01:00
subprocess.h subprocess: implement proper detached processes on POSIX 2020-02-16 22:08:48 +01:00
terminal-dummy.c
terminal-unix.c terminal-unix: stop trying to read when terminal disappears 2018-05-25 10:17:06 +02:00
terminal-win.c
terminal.h
threads.c
threads.h
timer-darwin.c
timer-linux.c build: remove nanosleep() check 2017-12-02 23:29:40 +01:00
timer-win2.c
timer.c timer: remove an unused helper function 2018-05-24 19:56:35 +02:00
timer.h demux, stream: readd cache-speed in some other form 2018-12-06 10:30:41 +01:00
w32_keyboard.c
w32_keyboard.h
win32-console-wrapper.c win32-console-wrapper: silence missing prototype warnings 2019-05-10 21:06:58 +10:00
windows_utils.c
windows_utils.h