Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another attempt of support pty on windows with ConPTY api #155

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixed unit tests
  • Loading branch information
photostorm committed Oct 28, 2023
commit c3e5fb6a7b36fb6f77b5c9b95832c7854db19ead
4 changes: 4 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package pty
import (
"errors"
"io"
"time"
)

// ErrUnsupported is returned if a function is not
Expand All @@ -30,6 +31,8 @@ type Pty interface {

// WriteString is only used to identify Pty and Tty
WriteString(s string) (n int, err error)
SetDeadline(t time.Time) error

io.ReadWriteCloser
}

Expand All @@ -41,6 +44,7 @@ type Tty interface {
FdHolder

Name() string
SetDeadline(t time.Time) error

io.ReadWriteCloser
}
5 changes: 2 additions & 3 deletions io_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
package pty

import (
"testing"

"context"
"errors"
"os"
"runtime"
"sync"
"testing"
"time"
)

Expand Down Expand Up @@ -71,7 +70,7 @@ func TestReadClose(t *testing.T) {
}

// Open pty and setup watchdogs for graceful and not so graceful failure modes
func prepare(t *testing.T) (ptmx *os.File, done func()) {
func prepare(t *testing.T) (ptmx Pty, done func()) {
if runtime.GOOS == "darwin" {
t.Log("creack/pty uses blocking i/o on darwin intentionally:")
t.Log("> https://github.com/creack/pty/issues/52")
Expand Down
9 changes: 9 additions & 0 deletions pty_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"os"
"syscall"
"time"
"unsafe"

"golang.org/x/sys/windows"
Expand Down Expand Up @@ -137,6 +138,10 @@ func (p *WindowsPty) Close() error {
return err
}

func (t *WindowsPty) SetDeadline(value time.Time) error {
return nil
}

func (t *WindowsTty) Name() string {
return t.r.Name()
}
Expand All @@ -158,6 +163,10 @@ func (t *WindowsTty) Close() error {
return t.w.Close()
}

func (t *WindowsTty) SetDeadline(value time.Time) error {
return nil
}

func procCreatePseudoConsole(hInput windows.Handle, hOutput windows.Handle, dwFlags uint32, consoleHandle *windows.Handle) error {
var r0 uintptr
var err error
Expand Down