没有合适的资源?快使用搜索试试~ 我知道了~
创建可交互进程
0 下载量 16 浏览量
2021-01-20
13:17:39
上传
评论
收藏 47KB PDF 举报
温馨提示
试读
9页
go language 版本: 需要依赖winpty.dll 和 winpty-agent.exe winpty.go package winpty import ( fmt io os syscall unsafe ) type Options struct { // DllDir is the path to winpty.dll and winpty-agent.exe DllDir string // FilePath sets the title of the console FilePath string // Command is the
资源详情
资源评论
资源推荐
创建可交互进程创建可交互进程
go language 版本:
需要依赖winpty.dll 和 winpty-agent.exe
winpty.go
package winpty
import (
"fmt"
"io"
"os"
"syscall"
"unsafe"
)
type Options struct {
// DllDir is the path to winpty.dll and winpty-agent.exe
DllDir string
// FilePath sets the title of the console
FilePath string
// Command is the full command to launch
Command string
// Dir sets the current working directory for the command
Dir string
// Env sets the environment variables. Use the format VAR=VAL.
Env []string
// AgentFlags to pass to agent config creation
AgentFlags uint64
SpawnFlag uint32
MouseModes int
// Initial size for Columns and Rows
InitialCols uint32
InitialRows uint32
agentTimeoutMs *uint64
}
type WinPTY struct {
Stdin *os.File
Stdout *os.File
Stderr *os.File
pty uintptr
winptyConfigT uintptr
procHandle uintptr
closed bool
exitCode *int
}
func (pty *WinPTY) Pid() int {
pid, _, _ :=GetProcessId.Call(pty.procHandle)
return int(pid)
}
//这里不能讲一个file结构体赋值给一个WriteCloser的原因是file结构体的Close方法的第一个参数是一个file指针而不是file指针,也就是说接口方法的对应的结构体方法的第一个参数可以是结构体对或者结构体指针
func (pty *WinPTY) GetStdin() io.Reader {
return pty.Stdin//这里的类型是机构体指针还是结构体本身取决于该结构体实现的接口方法的第一个参数是指针还是结构体
}
func (pty *WinPTY) GetStdout() io.Writer {
weixin_38569166
- 粉丝: 7
- 资源: 878
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0