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 Universal Windows Plaform (UWP) support 2017-06-29 10:36:16 +02:00
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 osx: change license of OSX and cocoa files to LGPL 2017-06-24 16:29:22 +02:00
macosx_touchbar.m osx: change license of OSX and cocoa files to LGPL 2017-06-24 16:29:22 +02:00
macosx_versions.h osx: change license of OSX and cocoa files to LGPL 2017-06-24 16:29:22 +02:00
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 Universal Windows Plaform (UWP) support 2017-06-29 10:36:16 +02:00
path-win.c win32: build with -DINITGUID 2016-09-28 21:38:52 +10:00
path.h Universal Windows Plaform (UWP) support 2017-06-29 10:36:16 +02:00
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 Fix use of ISC license 2017-04-15 16:20:00 +02:00
strnlen.h osdep: make use of HAVE_ANDROID 2018-08-20 17:16:22 +02:00
subprocess-dummy.c build: change how some OS specific source files are selected 2017-06-29 10:30:16 +02:00
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 build: change how some OS specific source files are selected 2017-06-29 10:30:16 +02:00
terminal-unix.c terminal-unix: stop trying to read when terminal disappears 2018-05-25 10:17:06 +02:00
terminal-win.c terminal: remove unused return value 2017-06-27 18:08:56 +02:00
terminal.h terminal: remove unused return value 2017-06-27 18:08:56 +02:00
threads.c Revert "osdep: NetBSD pthread_setname_np()" 2017-06-22 13:17:40 +02:00
threads.h
timer-darwin.c
timer-linux.c build: remove nanosleep() check 2017-12-02 23:29:40 +01:00
timer-win2.c Universal Windows Plaform (UWP) support 2017-06-29 10:36:16 +02:00
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_common: handle media keys 2017-08-05 02:38:44 +10:00
w32_keyboard.h w32_common: handle media keys 2017-08-05 02:38:44 +10:00
win32-console-wrapper.c win32-console-wrapper: silence missing prototype warnings 2019-05-10 21:06:58 +10:00
windows_utils.c vo_opengl: angle: rewrite with custom swap chain 2017-02-07 22:45:07 +11:00
windows_utils.h win32: add COM-specific SAFE_RELEASE to windows_utils.h 2017-01-30 00:22:30 +11:00