Feat/multi console v2 enhanced#3312
Conversation
bdb21c2 to
2f37961
Compare
rminnich
left a comment
There was a problem hiding this comment.
overall: seems the best one yet.
| return func(c *exec.Cmd) { | ||
| if mtty { | ||
| ww, err := openFn(ttyNames) | ||
| if err != nil { |
There was a problem hiding this comment.
you'll need to remove the print, it's a package. You can return an error however.
There was a problem hiding this comment.
It return a function - if we would want to return an error we would need to modify the mod function as well to be able to return an error. I did not wanted to change the flow here - so I'd just return.
There was a problem hiding this comment.
so how about this. You want to use all the available consoles, which will fail if you return early if just one fails.
You might use errors.Join accumulate a list of errors, and accumulate your list of consoles too.
Is the problem that the caller of the modifier will quit with a non-null error?
It would be nice if you could return with
zero or more consoles, error
the caller can print the error, if it is non-nil, and use whatever consoles are returned.
This is similar to what io readers do: they can return data AND an error and let you pick what to do.
This is one of those cases where you want to know if something happened, but you want to try all the things.
I hate to see packages just print stuff to stderr because it makes it so hard to read the GitHub CI output when all these random messages appear.
There was a problem hiding this comment.
I agree that it makes generally sense to catch potential errors here but that would require a larger rework as we return a CommandModifier which currently is defined as type CommandModifier func(c *exec.Cmd). We would need to modify that type to also return errors which means changing every command modifier that currently exist as well. That's why Chris didn't want to change a lot here as the scope of the PR would be much broader then.
| } | ||
| } | ||
|
|
||
| func Raw(r *os.File) error { |
There was a problem hiding this comment.
did you have to break all this out? There is a Raw function in one of the packages?
If there is not a raw function, can you consider adding this to a package, so others can use it? It's a shame to have this only in libinit.
There was a problem hiding this comment.
I agree to move this out. Is was copied into the libinit package for the initial PoC but for this PR it should be moved to an appropriate place. Will do so.
| _, err := io.Copy(m, t) | ||
| if err != nil { | ||
| log.Printf("Error copying output from command to PTM: %v", err) | ||
| } |
There was a problem hiding this comment.
you might consider passing in an io.Writer for the package to log errors to, I can see where this kind of logging might be useful, but just directly printing like this can really mess up output.
| return func(c *exec.Cmd) { | ||
| if mtty { | ||
| ww, err := openFn(ttyNames) | ||
| if err != nil { |
There was a problem hiding this comment.
so how about this. You want to use all the available consoles, which will fail if you return early if just one fails.
You might use errors.Join accumulate a list of errors, and accumulate your list of consoles too.
Is the problem that the caller of the modifier will quit with a non-null error?
It would be nice if you could return with
zero or more consoles, error
the caller can print the error, if it is non-nil, and use whatever consoles are returned.
This is similar to what io readers do: they can return data AND an error and let you pick what to do.
This is one of those cases where you want to know if something happened, but you want to try all the things.
I hate to see packages just print stuff to stderr because it makes it so hard to read the GitHub CI output when all these random messages appear.
This commit enables to write from multiple consoles to the shell. This is a follow-up of the multi-writer support that enables output on all shells defined in the kernel cmdline. Signed-off-by: Christian Walter <christian.walter@9elements.com>
Signed-off-by: Christian Walter <christian.walter@9elements.com>
50f4305 to
ffebd3f
Compare
Signed-off-by: Marvin Drees <marvin.drees@9elements.com>
ffebd3f to
f55983b
Compare
|
Looks like the PTY based console runs into the same issue you mentioned earlier today with the gosh console decorators. It sometimes renders the prompt in the middle of the screen/serial and causes odd placements. I will create another PR changing the defaults as discussed. |
Signed-off-by: Marvin Drees <marvin.drees@9elements.com>
|
not sure this is helpful but .... got into a good talk with brho@ re this console stuff. It came up as an issue on something else. There is code that basically returns the equivalent of socketpair for a pty pair: To use it: and for IO: This is from cmds/exp/pflask, it works, the shell thinks it's on a tty, etc. This is what I think you need to correctly set up the multi console environment. |
|
Currently cleaning this up here: https://github.com/9elements/u-root/tree/linuxboot-fix and updating this PR once it works under multiple different environments. |
All good things are three.
This PR brings in Multi-console output and input support.