]> git.ipfire.org Git - thirdparty/lxc.git/commit
lxc-attach: fix redirection - stderr
authorChristian Brauner <christian.brauner@mailbox.org>
Fri, 4 Mar 2016 18:32:00 +0000 (19:32 +0100)
committerChristian Brauner <christian.brauner@mailbox.org>
Fri, 4 Mar 2016 23:38:39 +0000 (00:38 +0100)
commitd96556572ce4e64837c03eec1f64121a2bc8a3f8
tree3421ba3c80180ada2ee660e5de45bbb08ff3e969
parent6861fb2291e63769d19b32ad0ca766146837580c
lxc-attach: fix redirection - stderr

So that we can do things like:

lxc-attach -n a -- sh -c 'echo ERR >&2' > /dev/null

There seems to be no easy way to discern when we need to write to stderr
instead of stdout when we receive an event on the master fd of an allocated
pty. So we're using a "trick"/"hack". We write to STDOUT_FILENO if it refers to
a pty. If STDOUT_FILENO does not refer to a pty we check whether STDERR_FILENO
refers to a pty and if so write to it.

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
src/lxc/lxc_attach.c