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

Redirect child processes' stderr to the parent stdout #63

Merged
merged 1 commit into from
Feb 28, 2024
Merged
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: 4 additions & 0 deletions builder/chroot.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ import (
"github.com/getsolus/libosdev/commands"
)

func init() {
commands.SetStderr(os.Stdout)
}

// Chroot will attempt to spawn a chroot in the overlayfs system.
func (p *Package) Chroot(notif PidNotifier, pman *EopkgManager, overlay *Overlay) error {
slog.Debug("Beginning chroot", "profile", overlay.Back.Name, "version", p.Version,
Expand Down
4 changes: 2 additions & 2 deletions builder/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func ChrootExec(notif PidNotifier, dir, command string) error {
args := []string{dir, "/bin/sh", "-c", command}
c := exec.Command("chroot", args...)
c.Stdout = os.Stdout
c.Stderr = os.Stderr
c.Stderr = os.Stdout
c.Stdin = nil
c.Env = ChrootEnvironment
c.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
Expand All @@ -212,7 +212,7 @@ func ChrootExecStdin(notif PidNotifier, dir, command string) error {
args := []string{dir, "/bin/sh", "-c", command}
c := exec.Command("chroot", args...)
c.Stdout = os.Stdout
c.Stderr = os.Stderr
c.Stderr = os.Stdout
c.Stdin = os.Stdin
c.Env = ChrootEnvironment

Expand Down
1 change: 1 addition & 0 deletions cli/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
)

func init() {
commands.SetStderr(os.Stdout)
cmd.Register(&Init)
cmd.Register(&cmd.Help)
}
Expand Down