From c84c18f960104fb94ad9d2132644a18e2f05979d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 6 Sep 2023 19:50:15 +0800 Subject: [PATCH] platform: Fix crash on android --- experimental/libbox/log.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/experimental/libbox/log.go b/experimental/libbox/log.go index 18332ef9..3e442b92 100644 --- a/experimental/libbox/log.go +++ b/experimental/libbox/log.go @@ -4,6 +4,7 @@ package libbox import ( "os" + "runtime" "golang.org/x/sys/unix" ) @@ -18,12 +19,14 @@ func RedirectStderr(path string) error { if err != nil { return err } - if sUserID > 0 { - err = outputFile.Chown(sUserID, sGroupID) - if err != nil { - outputFile.Close() - os.Remove(outputFile.Name()) - return err + if runtime.GOOS != "android" { + if sUserID > 0 { + err = outputFile.Chown(sUserID, sGroupID) + if err != nil { + outputFile.Close() + os.Remove(outputFile.Name()) + return err + } } } err = unix.Dup2(int(outputFile.Fd()), int(os.Stderr.Fd()))