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

add mods #106

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/containerd/go-runc
module github.com/beam-cloud/go-runc

go 1.20
go 1.21

require (
github.com/containerd/console v1.0.3
Expand Down
14 changes: 14 additions & 0 deletions runc.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ type CreateOpts struct {
IO
// PidFile is a path to where a pid file should be created
PidFile string
ConfigPath string
OutputWriter io.Writer
ConsoleSocket ConsoleSocket
Detach bool
NoPivot bool
Expand Down Expand Up @@ -166,6 +168,9 @@ func (o *CreateOpts) args() (out []string, err error) {
if len(o.ExtraArgs) > 0 {
out = append(out, o.ExtraArgs...)
}
if o.ConfigPath != "" {
out = append(out, "--config", o.ConfigPath)
}
return out, nil
}

Expand Down Expand Up @@ -233,6 +238,7 @@ type ExecOpts struct {
Detach bool
Started chan<- int
ExtraArgs []string
OutputWriter io.Writer
}

func (o *ExecOpts) args() (out []string, err error) {
Expand Down Expand Up @@ -284,6 +290,10 @@ func (r *Runc) Exec(context context.Context, id string, spec specs.Process, opts
if opts.IO != nil {
opts.Set(cmd)
}
if opts.OutputWriter != nil {
cmd.Stdout = opts.OutputWriter
cmd.Stderr = opts.OutputWriter
}
if cmd.Stdout == nil && cmd.Stderr == nil {
data, err := r.cmdOutput(cmd, true, opts.Started)
defer putBuf(data)
Expand Down Expand Up @@ -332,6 +342,10 @@ func (r *Runc) Run(context context.Context, id, bundle string, opts *CreateOpts)
if opts.IO != nil {
opts.Set(cmd)
}
if opts.OutputWriter != nil {
cmd.Stdout = opts.OutputWriter
cmd.Stderr = opts.OutputWriter
}
cmd.ExtraFiles = opts.ExtraFiles
ec, err := r.startCommand(cmd)
if err != nil {
Expand Down
Loading