-
Notifications
You must be signed in to change notification settings - Fork 259
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
Add new exec package for host process containers #1233
Conversation
Don't be scared of the 347 changed files haha, 90% is just new files from bumping golang.org/x/sys in the main go.mod and in /test. |
0a2e90d
to
dbe2d29
Compare
lgtm |
@ambarve PTAL |
This change adds a new exec package thats main goal is to run external processes on Windows. Unfortunately due to a couple things that can't be accomplished with the stdlib os/exec package, this new package is meant to replace how processes for host process containers are launched. The main shortcomings are not being able to pass in a pseudo console to use for tty scenarios, and not being able to start a process assigned to a job object instead of doing the Create -> Assign dance. Both of these issue are centered around not having access to the process thread attribute list that is setup inside of syscall.StartProcess. This is needed to be able to properly setup both cases, as it requires calling UpdateProcThreadAttribute and passing in what's necessary for both scenarios. Signed-off-by: Daniel Canter <dcanter@microsoft.com>
* Remove conpty comments * Terminate the process if os.FindProcess doesn't work. Signed-off-by: Daniel Canter <dcanter@microsoft.com>
This change adds pseudo console support to the exec package. Signed-off-by: Daniel Canter <dcanter@microsoft.com>
x/sys/windows has the Proc thread attribute work we need already, so swap to this instead of our own definitions. Signed-off-by: Daniel Canter <dcanter@microsoft.com>
@katiewasnothere @anmaxvl Anyone able to take a look at this? |
1. Add comment regarding thread safety 2. Add check on job object test to make sure the pids slice has at least one element before testing what's in [0]. 3. Change stdioOurEnd -> stdioPipesOurSide and stdioProcEnd -> stdioPipesProcSide. 4. Misc. clarification comments on fields and methods. 5. Change from raw string literal in powershell test to string with carriage return at the end. Signed-off-by: Daniel Canter <dcanter@microsoft.com>
internal/exec/exec.go
Outdated
return fmt.Errorf("failed to create process: %w", err) | ||
} | ||
// Don't need the thread handle for anything. | ||
defer windows.CloseHandle(windows.Handle(pi.Thread)) //nolint:errcheck |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we change this to
defer func() {
_ = windows.CloseHandle(windows.Handle(pi.Thread))
}()
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
internal/exec/exec.go
Outdated
// Either: New() -> e.Start() -> e.Wait() | ||
// | ||
// or: New() -> e.Run() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add something about ExitCode and Pid, etc I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small requests otherwise lgtm
1. Add nod to using e.ExitCode() in the process lifecycle comment 2. Change to different way to defer close the thread handle to avoid nolint comment Signed-off-by: Daniel Canter <dcanter@microsoft.com>
* Add new exec package for host process containers This change adds a new exec package thats main goal is to run external processes on Windows. Unfortunately due to a couple things that can't be accomplished with the stdlib os/exec package, this new package is meant to replace how processes for host process containers are launched. The main shortcomings are not being able to pass in a pseudo console to use for tty scenarios, and not being able to start a process assigned to a job object instead of doing the Create -> Assign dance. Both of these issue are centered around not having access to the process thread attribute list that is setup inside of syscall.StartProcess. This is needed to be able to properly setup both cases, as it requires calling UpdateProcThreadAttribute and passing in what's necessary for both scenarios. This change ends up bumping x/sys/windows as well to grab some fixes for the attribute list functionality. Signed-off-by: Daniel Canter <dcanter@microsoft.com> (cherry picked from commit 2314362) Signed-off-by: Daniel Canter <dcanter@microsoft.com>
* Add new exec package for host process containers This change adds a new exec package thats main goal is to run external processes on Windows. Unfortunately due to a couple things that can't be accomplished with the stdlib os/exec package, this new package is meant to replace how processes for host process containers are launched. The main shortcomings are not being able to pass in a pseudo console to use for tty scenarios, and not being able to start a process assigned to a job object instead of doing the Create -> Assign dance. Both of these issue are centered around not having access to the process thread attribute list that is setup inside of syscall.StartProcess. This is needed to be able to properly setup both cases, as it requires calling UpdateProcThreadAttribute and passing in what's necessary for both scenarios. This change ends up bumping x/sys/windows as well to grab some fixes for the attribute list functionality. Signed-off-by: Daniel Canter <dcanter@microsoft.com> (cherry picked from commit 2314362) Signed-off-by: Daniel Canter <dcanter@microsoft.com>
* Add new exec package for host process containers This change adds a new exec package thats main goal is to run external processes on Windows. Unfortunately due to a couple things that can't be accomplished with the stdlib os/exec package, this new package is meant to replace how processes for host process containers are launched. The main shortcomings are not being able to pass in a pseudo console to use for tty scenarios, and not being able to start a process assigned to a job object instead of doing the Create -> Assign dance. Both of these issue are centered around not having access to the process thread attribute list that is setup inside of syscall.StartProcess. This is needed to be able to properly setup both cases, as it requires calling UpdateProcThreadAttribute and passing in what's necessary for both scenarios. This change ends up bumping x/sys/windows as well to grab some fixes for the attribute list functionality. Signed-off-by: Daniel Canter <dcanter@microsoft.com>
This change adds a new exec package thats main goal is to run
external processes on Windows. Unfortunately due to a couple
things that can't be accomplished with the stdlib os/exec package,
this new package is meant to replace how processes for host process
containers are launched.
The main shortcomings for os/exec are not being able to pass in a pseudo console to use
for tty scenarios, and not being able to start a process assigned to a job object
instead of doing the Create -> Assign dance. Both of these issue are centered
around not having access to the process thread attribute list that is setup inside
of syscall.StartProcess. This is needed to be able to properly setup both cases,
as it requires calling UpdateProcThreadAttribute and passing in what's necessary
for both scenarios.
Signed-off-by: Daniel Canter dcanter@microsoft.com