platform: Fix crash on android

This commit is contained in:
世界 2023-09-06 19:50:15 +08:00
parent 1402bdab41
commit c84c18f960
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
1 changed files with 9 additions and 6 deletions

View File

@ -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()))