-
Notifications
You must be signed in to change notification settings - Fork 34
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
Get both stdout and stderr #12
Comments
Sorry for the slow response. Writing both stdout and stderr to the same file is tricky, because of non-atomic IO, possible race conditions, the buffering of stdout, possible more problems. Making this to work across platforms is not an easy task imo. But if you have some ideas, I would be happy to hear them. |
Maybe if we just redirect with |
Sorry for not responding in time. wrapper = function(expr, dst) {
fp = file(dst, open = "wt")
sink(file = fp)
sink(file = fp, type = "message")
on.exit({ sink(type = "message"); sink(type = "output"); close(fp) })
expr
} This is basically what I use in batchtools and it works quite okay most of the time. Your solution might be even better, because you could also record output from C which does not use |
Redirection works fine on windows, even ...
if (ignore.stdout)
command <- paste(command, ">/dev/null")
if (ignore.stderr)
command <- paste(command, "2>/dev/null")
... So I think this will be fine. |
Oh, wait. If I redirect both to the same file, then I cannot return them separately..... |
OK, looks like there is no way to collect stdout and stderr in the right order...... I can "fix" the current behavior, in that I can make sure that if you redirect output and error to the same file, then they will be in the file, although in the wrong order.... |
The order of the output is incorrect, though.
Hmmm, looking at this again, |
I'm wondering if it is possible to get both output streams together, with lines in the right (chronological) order. One way to achieve this with
system2
is to redirect stdout and stderr to the same connection, but this does not seem to work with callr, c.f. the following small snippet:The text was updated successfully, but these errors were encountered: