Fix poweroff/reboot/halt Kernal panic bug by avoding unnecessary log.Fatal() calls (#7)

Reviewed-on: #7
pull/8/head
James Mills 2 months ago
parent 4e6d289088
commit f048a102b4
  1. 2
      cmd/init/main.go
  2. 3
      internal/applets/tee/tee.go
  3. 4
      internal/ssh.go

@ -163,7 +163,7 @@ func respawn(ctx context.Context, cmd string, args ...string) {
for {
select {
case err := <-run(cmd, args...):
log.Println("failed to start respawn process %q: %s", cmd, err)
log.Printf("failed to start respawn process %q: %s\n", cmd, err)
return
case <-ctx.Done():
return

@ -5,7 +5,6 @@ import (
"fmt"
"io"
"io/ioutil"
"log"
"os"
"git.mills.io/prologic/gonix/internal/applets"
@ -76,7 +75,7 @@ func tee(w io.Writer, args []string, opt *Option) error {
} else {
f, err := os.OpenFile(arg, os.O_WRONLY|os.O_CREATE, 0644)
if err != nil {
log.Fatal(err)
return fmt.Errorf("error opening %q for writing: %w", arg, err)
}
if _, err := f.Write(bytes); err != nil {
return fmt.Errorf("error writing to file: %w", err)

@ -239,5 +239,7 @@ func StartSSHServer(ctx context.Context) {
log.Panicln(err.Error())
return
}
log.Fatal(svr.Run(ctx))
if err := svr.Run(ctx); err != nil {
log.Printf("error running ssh server: %s\n", err)
}
}

Loading…
Cancel
Save