Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--stderr=/dev/fd/1 doesn't work #44

Closed
seirl opened this issue Jan 31, 2018 · 5 comments
Closed

--stderr=/dev/fd/1 doesn't work #44

seirl opened this issue Jan 31, 2018 · 5 comments

Comments

@seirl
Copy link
Contributor

seirl commented Jan 31, 2018

The workaround for piping stderr to stdout suggested here: f7b60f2

doesn't seem to work:

$ isolate --box-id 0 --cg -p --stderr=/dev/fd/1 --stdout=stdout --run -- /bin/bash -c "echo a >&2; echo b; echo a >&2; echo b"     
OK (0.000 sec real, 0.019 sec wall)
$ cat /var/lib/isolate/0/box/stdout 
b
b

Any idea why that is the case?

@zopieux
Copy link
Contributor

zopieux commented Feb 15, 2018

@gollux any idea or workaround? Thanks!

@gollux
Copy link
Member

gollux commented Feb 21, 2018

In fact, it works, but in a somewhat unexpected way: you really get both fd 1 and fd 2 pointing to the same file, but each fd has its own position in the file, so the echo'ed strings are overwriting one another.

Cloning the fd would have more sense, wouldn't it?

@seirl
Copy link
Contributor Author

seirl commented Feb 21, 2018

Cloning the fd would have more sense, wouldn't it?

That's what the code was doing before, yeah, but now I'm not sure what would be a good way to have the same feature again from the outside, especially with all the permission/setuid stuff that prevent us from opening /box files from the caller.

@gollux
Copy link
Member

gollux commented Feb 22, 2018

I just added a --stderr-to-stdout switch, which asks for the old default behavior.

I was thinking about adding a generic file redirection mechanism, but I failed to find any nice syntax for that. Nor did I find any other applications.

@gollux gollux closed this as completed Feb 22, 2018
@seirl
Copy link
Contributor Author

seirl commented Feb 22, 2018

This is great, I'll try that as soon as possible! This mirrors the API we have in https://github.com/prologin/camisole/blob/master/camisole/isolate.py#L171 . The use case is when we have a single display and we want to preserve the timing of the logging, so we can't just concatenate the outputs. I also can't think of an use case for redirecting other files/fds so I think the current patch is exactly what was needed.

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants