summaryrefslogtreecommitdiffstats
path: root/player/lua.c
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2017-12-17 01:25:23 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-02-13 20:16:01 -0800
commit8f9785d128eef0eae656d32d664ae1a8bff0bb12 (patch)
tree61250cdc4cd0505492e245757450e1a672713640 /player/lua.c
parentf17246fec15963e7cc098cf7ba7263ad02877b99 (diff)
downloadmpv-8f9785d128eef0eae656d32d664ae1a8bff0bb12.tar.bz2
mpv-8f9785d128eef0eae656d32d664ae1a8bff0bb12.tar.xz
lua+js: Implement utils.getpid()
Usable for uniquely identifying mpv instances from subprocesses, controlling mpv with AppleScript, ... Adds a new mp_getpid() wrapper for cross-platform reasons.
Diffstat (limited to 'player/lua.c')
-rw-r--r--player/lua.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/player/lua.c b/player/lua.c
index d928fdfa46..778830976c 100644
--- a/player/lua.c
+++ b/player/lua.c
@@ -44,6 +44,7 @@
#include "osdep/subprocess.h"
#include "osdep/timer.h"
#include "osdep/threads.h"
+#include "osdep/getpid.h"
#include "stream/stream.h"
#include "sub/osd.h"
#include "core.h"
@@ -1252,6 +1253,12 @@ static int script_subprocess_detached(lua_State *L)
return 1;
}
+static int script_getpid(lua_State *L)
+{
+ lua_pushnumber(L, mp_getpid());
+ return 1;
+}
+
static int script_parse_json(lua_State *L)
{
mp_lua_optarg(L, 2);
@@ -1338,6 +1345,7 @@ static const struct fn_entry utils_fns[] = {
FN_ENTRY(join_path),
FN_ENTRY(subprocess),
FN_ENTRY(subprocess_detached),
+ FN_ENTRY(getpid),
FN_ENTRY(parse_json),
FN_ENTRY(format_json),
{0}