On Wed, Mar 08, 2017 at 10:08:29PM +0000, Élie Deloumeau-Prigent wrote: > Hello everyone, > > Is there any way to store attach_wait output into a variable? > > Thanks in advance! > > Élie.
There is, but it's not exactly trivial. attach_wait spawns a subprocess through fork(), so the python process memory space isn't shared and the output therefore goes to stdout/stderr. What we did in the past for lxc-ls which needed something like that was have the main python process create a temporary file with tempfile.mkstemp(), then pass the fd as an argument to the function run by attach_wait, have the function redirect the output towards that fd and finally having the main process rewind and read from the fd after attach_wait returns. -- Stéphane Graber Ubuntu developer http://www.ubuntu.com
signature.asc
Description: PGP signature
_______________________________________________ lxc-users mailing list [email protected] http://lists.linuxcontainers.org/listinfo/lxc-users
