mirror of
https://github.com/creack/pty.git
synced 2026-04-01 11:07:11 +09:00
cleanup some unused fields
This commit is contained in:
@@ -28,12 +28,10 @@ import (
|
||||
// A cmd cannot be reused after calling its Run, Output or CombinedOutput
|
||||
// methods.
|
||||
type windowExecCmd struct {
|
||||
cmd *exec.Cmd
|
||||
waitCalled bool
|
||||
consoleHandle syscall.Handle
|
||||
tty *WindowsTty
|
||||
conPty *WindowsPty
|
||||
attrList *windows.ProcThreadAttributeListContainer
|
||||
cmd *exec.Cmd
|
||||
waitCalled bool
|
||||
conPty *WindowsPty
|
||||
attrList *windows.ProcThreadAttributeListContainer
|
||||
}
|
||||
|
||||
var errProcessNotStarted = errors.New("exec: process has not started yet")
|
||||
@@ -41,7 +39,7 @@ var errProcessNotStarted = errors.New("exec: process has not started yet")
|
||||
func (c *windowExecCmd) close() error {
|
||||
c.attrList.Delete()
|
||||
_ = c.conPty.Close()
|
||||
_ = c.tty.Close()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -109,14 +109,6 @@ func (p *WindowsPty) WriteString(s string) (int, error) {
|
||||
return p.w.WriteString(s)
|
||||
}
|
||||
|
||||
func (p *WindowsPty) InputPipe() *os.File {
|
||||
return p.w
|
||||
}
|
||||
|
||||
func (p *WindowsPty) OutputPipe() *os.File {
|
||||
return p.r
|
||||
}
|
||||
|
||||
func (p *WindowsPty) UpdateProcThreadAttribute(attrList *windows.ProcThreadAttributeListContainer) error {
|
||||
var err error
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ func StartWithSize(c *exec.Cmd, sz *Winsize) (Pty, error) {
|
||||
//
|
||||
// This should generally not be needed. Used in some edge cases where it is needed to create a pty
|
||||
// without a controlling terminal.
|
||||
func StartWithAttrs(c *exec.Cmd, sz *Winsize, attrs *syscall.SysProcAttr) (_ Pty, err error) {
|
||||
pty, tty, err := open()
|
||||
func StartWithAttrs(c *exec.Cmd, sz *Winsize, attrs *syscall.SysProcAttr) (Pty, error) {
|
||||
pty, _, err := open()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -42,7 +42,6 @@ func StartWithAttrs(c *exec.Cmd, sz *Winsize, attrs *syscall.SysProcAttr) (_ Pty
|
||||
defer func() {
|
||||
// unlike unix command exec, do not close tty unless error happened
|
||||
if err != nil {
|
||||
_ = tty.Close()
|
||||
_ = pty.Close()
|
||||
}
|
||||
}()
|
||||
@@ -60,16 +59,13 @@ func StartWithAttrs(c *exec.Cmd, sz *Winsize, attrs *syscall.SysProcAttr) (_ Pty
|
||||
// do not use os/exec.Start since we need to append console handler to startup info
|
||||
|
||||
w := windowExecCmd{
|
||||
cmd: c,
|
||||
waitCalled: false,
|
||||
consoleHandle: syscall.Handle(tty.Fd()),
|
||||
tty: tty.(*WindowsTty),
|
||||
conPty: pty.(*WindowsPty),
|
||||
cmd: c,
|
||||
waitCalled: false,
|
||||
conPty: pty.(*WindowsPty),
|
||||
}
|
||||
|
||||
err = w.Start()
|
||||
if err != nil {
|
||||
_ = tty.Close()
|
||||
_ = pty.Close()
|
||||
return nil, err
|
||||
}
|
||||
@@ -176,7 +172,7 @@ func (c *windowExecCmd) Start() error {
|
||||
// Need EXTENDED_STARTUPINFO_PRESENT as we're making use of the attribute list field.
|
||||
flags := sys.CreationFlags | uint32(windows.CREATE_UNICODE_ENVIRONMENT) | windows.EXTENDED_STARTUPINFO_PRESENT
|
||||
|
||||
c.attrList, err = windows.NewProcThreadAttributeList(3)
|
||||
c.attrList, err = windows.NewProcThreadAttributeList(1)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to initialize process thread attribute list: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user