1
0
Fork 0
mirror of https://repo.or.cz/socat.git synced 2025-07-11 14:23:23 +00:00

EXEC and SYSTEM with stderr injected socat messages into the data stream

This commit is contained in:
Gerhard Rieger 2008-06-07 10:14:56 +02:00
parent c4751d50ec
commit ad4bd0d9db
9 changed files with 126 additions and 67 deletions

View file

@ -1,5 +1,5 @@
/* source: xio-exec.c */
/* Copyright Gerhard Rieger 2001-2006 */
/* Copyright Gerhard Rieger 2001-2008 */
/* Published under the GNU General Public License V.2, see file COPYING */
/* this file contains the source for opening addresses of exec type */
@ -32,6 +32,7 @@ static int xioopen_exec(int argc, const char *argv[], struct opt *opts,
) {
int status;
bool dash = false;
int duptostderr;
if (argc != 2) {
Error3("\"%s:%s\": wrong number of parameters (%d instead of 1)", argv[0], argv[1], argc-1);
@ -39,7 +40,7 @@ static int xioopen_exec(int argc, const char *argv[], struct opt *opts,
retropt_bool(opts, OPT_DASH, &dash);
status = _xioopen_foxec(xioflags, &fd->stream, groups, &opts);
status = _xioopen_foxec(xioflags, &fd->stream, groups, &opts, &duptostderr);
if (status < 0) return status;
if (status == 0) { /* child */
const char *ends[] = { " ", NULL };
@ -118,6 +119,11 @@ static int xioopen_exec(int argc, const char *argv[], struct opt *opts,
return STAT_NORETRY;
}
/* only now redirect stderr */
if (duptostderr >= 0) {
diag_dup();
Dup2(duptostderr, 2);
}
Notice1("execvp'ing \"%s\"", token);
result = Execvp(token, pargv);
/* here we come only if execvp() failed */