This commit is contained in:
Liang Ding 2022-09-29 21:52:01 +08:00
parent 56129699b9
commit 69a9713776
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
38 changed files with 193 additions and 438 deletions

View file

@ -1,24 +0,0 @@
// SiYuan - Build Your Eternal Digital Garden
// Copyright (c) 2020-present, b3log.org
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//go:build !windows
package util
import "os/exec"
func CmdAttr(cmd *exec.Cmd) {
}

View file

@ -1,26 +0,0 @@
// SiYuan - Build Your Eternal Digital Garden
// Copyright (c) 2020-present, b3log.org
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package util
import (
"os/exec"
"syscall"
)
func CmdAttr(cmd *exec.Cmd) {
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
}

View file

@ -417,14 +417,14 @@ func Kill(pid string) {
} else {
kill = exec.Command("kill", "-9", pid)
}
CmdAttr(kill)
gulu.CmdAttr(kill)
kill.CombinedOutput()
}
func PidByPort(port string) (ret string) {
if gulu.OS.IsWindows() {
cmd := exec.Command("cmd", "/c", "netstat -ano | findstr "+port)
CmdAttr(cmd)
gulu.CmdAttr(cmd)
data, err := cmd.CombinedOutput()
if nil != err {
logging.LogErrorf("netstat failed: %s", err)
@ -444,7 +444,7 @@ func PidByPort(port string) (ret string) {
}
cmd := exec.Command("lsof", "-Fp", "-i", ":"+port)
CmdAttr(cmd)
gulu.CmdAttr(cmd)
data, err := cmd.CombinedOutput()
if nil != err {
logging.LogErrorf("lsof failed: %s", err)
@ -507,7 +507,7 @@ func getPandocVer(binPath string) (ret string) {
}
cmd := exec.Command(binPath, "--version")
CmdAttr(cmd)
gulu.CmdAttr(cmd)
data, err := cmd.CombinedOutput()
if nil == err && strings.HasPrefix(string(data), "pandoc") {
parts := bytes.Split(data, []byte("\n"))
@ -527,7 +527,7 @@ func IsValidPandocBin(binPath string) bool {
}
cmd := exec.Command(binPath, "--version")
CmdAttr(cmd)
gulu.CmdAttr(cmd)
data, err := cmd.CombinedOutput()
if nil == err && strings.HasPrefix(string(data), "pandoc") {
return true