diff options
author | wm4 <wm4@nowhere> | 2015-01-01 20:04:38 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-01-01 20:04:38 +0100 |
commit | 44701238c73ba8f50fb16c675e2db3555902ac7a (patch) | |
tree | bb2db125fa0ca7c6774abe3ac99e44fb3c75c4aa /osdep/subprocess-win.c | |
parent | bafb9b22715313ef0049630228a744d7f2c9363b (diff) | |
download | mpv-44701238c73ba8f50fb16c675e2db3555902ac7a.tar.bz2 mpv-44701238c73ba8f50fb16c675e2db3555902ac7a.tar.xz |
subprocess: allow disabling redirection of stdout/stderr
If the stdout or stderr write callback is NULL, then don't redirect this
stream. Preparation for the next commit.
Not sure what to do on Windows; it seems STARTUPINFO doesn't allow
redirection only one of them. So just let them write nothing. For our
intended use-case (next commit), this is probably sensible.
Diffstat (limited to 'osdep/subprocess-win.c')
-rw-r--r-- | osdep/subprocess-win.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/osdep/subprocess-win.c b/osdep/subprocess-win.c index bdc78c939d..9edfca0f45 100644 --- a/osdep/subprocess-win.c +++ b/osdep/subprocess-win.c @@ -220,6 +220,10 @@ static int async_read(HANDLE file, void *buf, unsigned size, OVERLAPPED* ol) return 0; } +static void write_none(void *ctx, char *data, size_t size) +{ +} + int mp_subprocess(char **args, struct mp_cancel *cancel, void *ctx, subprocess_read_cb on_stdout, subprocess_read_cb on_stderr, char **error) @@ -233,8 +237,8 @@ int mp_subprocess(char **args, struct mp_cancel *cancel, void *ctx, char buf[4096]; subprocess_read_cb read_cb; } pipes[2] = { - { .read_cb = on_stdout }, - { .read_cb = on_stderr }, + { .read_cb = on_stdout ? on_stdout : write_none }, + { .read_cb = on_stderr ? on_stderr : write_none }, }; // If the function exits before CreateProcess, there was an init error |