-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: gogf#3370 fixed process parameter parsing failed on Windows for …
…package `gproc` (gogf#3386)
- Loading branch information
Showing
4 changed files
with
48 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. | ||
// | ||
// This Source Code Form is subject to the terms of the MIT License. | ||
// If a copy of the MIT was not distributed with this file, | ||
// You can obtain one at https://github.com/gogf/gf. | ||
|
||
//go:build !windows | ||
|
||
package gproc | ||
|
||
import "strings" | ||
|
||
func newProcess(p *Process, args []string, path string) *Process { | ||
if len(args) > 0 { | ||
// Exclude of current binary path. | ||
start := 0 | ||
if strings.EqualFold(path, args[0]) { | ||
start = 1 | ||
} | ||
p.Args = append(p.Args, args[start:]...) | ||
} | ||
return p | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. | ||
// | ||
// This Source Code Form is subject to the terms of the MIT License. | ||
// If a copy of the MIT was not distributed with this file, | ||
// You can obtain one at https://github.com/gogf/gf. | ||
|
||
//go:build windows | ||
|
||
package gproc | ||
|
||
import ( | ||
"syscall" | ||
|
||
"github.com/gogf/gf/v2/text/gstr" | ||
) | ||
|
||
// Because when the underlying parameters are passed in on the Windows platform, | ||
// escape characters will be added, causing some commands to fail. | ||
func newProcess(p *Process, args []string, path string) *Process { | ||
p.SysProcAttr = &syscall.SysProcAttr{} | ||
p.SysProcAttr.CmdLine = path + " " + gstr.Join(args, " ") | ||
return p | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters