summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaleb Bassi <calebjbassi@gmail.com>2018-12-12 18:18:43 -0800
committerCaleb Bassi <calebjbassi@gmail.com>2018-12-12 18:18:43 -0800
commitc1e7986ed0e75f1b86df52895490ec0b222ae2b2 (patch)
tree71e016df37dbd5ebbbad0b8c276db3202910f395
parente81b4c14c03edbc4aeef4cd76dbfebab5cac90bb (diff)
Fix stderr redirection on arm64
-rw-r--r--main.go7
-rw-r--r--src/logging/logging_arm64.go10
-rw-r--r--src/logging/logging_other.go12
3 files changed, 26 insertions, 3 deletions
diff --git a/main.go b/main.go
index 4c07460..9db162d 100644
--- a/main.go
+++ b/main.go
@@ -15,6 +15,7 @@ import (
"time"
"github.com/cjbassi/gotop/colorschemes"
+ "github.com/cjbassi/gotop/src/logging"
w "github.com/cjbassi/gotop/src/widgets"
ui "github.com/cjbassi/termui"
"github.com/docopt/docopt-go"
@@ -349,7 +350,7 @@ func eventLoop() {
}
}
-func logging() (*os.File, error) {
+func setupLogging() (*os.File, error) {
// make the config directory
if err := os.MkdirAll(configDir, 0755); err != nil {
return nil, fmt.Errorf("failed to make the configuration directory: %v", err)
@@ -369,7 +370,7 @@ func logging() (*os.File, error) {
}
func main() {
- lf, err := logging()
+ lf, err := setupLogging()
if err != nil {
stderrLogger.Fatalf("failed to setup logging: %v", err)
}
@@ -389,7 +390,7 @@ func main() {
}
defer ui.Close()
- syscall.Dup2(int(lf.Fd()), 2) // redirect stderr to logfile
+ logging.StderrToLogfile(lf)
setupGrid()
ui.Render(ui.Body)
diff --git a/src/logging/logging_arm64.go b/src/logging/logging_arm64.go
new file mode 100644
index 0000000..877a4b3
--- /dev/null
+++ b/src/logging/logging_arm64.go
@@ -0,0 +1,10 @@
+package logging
+
+import (
+ "os"
+ "syscall"
+)
+
+func StderrToLogfile(lf *os.File) {
+ syscall.Dup3(int(lf.Fd()), 2, 0)
+}
diff --git a/src/logging/logging_other.go b/src/logging/logging_other.go
new file mode 100644
index 0000000..aba2aa7
--- /dev/null
+++ b/src/logging/logging_other.go
@@ -0,0 +1,12 @@
+// +build !arm64
+
+package logging
+
+import (
+ "os"
+ "syscall"
+)
+
+func StderrToLogfile(lf *os.File) {
+ syscall.Dup2(int(lf.Fd()), 2)
+}