You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, so I came across this and it looks like a really cool library (thanks for making it!), and I was hoping to use it in a project I'm working on.
Basically, what I'm trying to implement is very similar to your shell example, except that the example isn't behaving the way I expected it to. Essentially, I'm looking to use this package from a background service on my system, and have that background service spawn a pty that a user can connect to and use normally by running screen /dev/ttys002 or similar.
When I run the shell example though, it seems to effectively run it in my current TTY, which is obviously not too helpful in my case. It seems this might be intended given the code, particularly with regard to the io.Copy routines reading/writing os.Stdout/os.Stdin, as well as the fact ptmx.Name() isn't outputted at all.
deferfunc() { _=term.Restore(int(os.Stdin.Fd()), oldState) }() // Best effort.
// Copy stdin to the pty and the pty to stdout.
// NOTE: The goroutine will keep reading until the next keystroke before returning.
goio.Copy(ptmx, os.Stdin)
goio.Copy(os.Stdout, ptmx)
I tried to play with the arguments to the IO functions and replace os.Std* with a handle to ptmx.Name(), and that got the shell to seem to not use the current TTY, but I still can't seem to do anything at all inside the screen connected to ptmx.Name(). No data echos no matter what I type (stty shows echo enabled though), and typing exit doesn't seem to reach bash because it doesn't exit.
I feel like I can't be far off at all from getting this to work, but I can't figure out what I'm missing. I'm also confused as to how the shell example was supposed to work in the first place. If you could point me in the right direction I'd really appreciate it.
Thanks so much
The text was updated successfully, but these errors were encountered:
Hey, so I came across this and it looks like a really cool library (thanks for making it!), and I was hoping to use it in a project I'm working on.
Basically, what I'm trying to implement is very similar to your shell example, except that the example isn't behaving the way I expected it to. Essentially, I'm looking to use this package from a background service on my system, and have that background service spawn a pty that a user can connect to and use normally by running
screen /dev/ttys002
or similar.When I run the shell example though, it seems to effectively run it in my current TTY, which is obviously not too helpful in my case. It seems this might be intended given the code, particularly with regard to the
io.Copy
routines reading/writingos.Stdout
/os.Stdin
, as well as the factptmx.Name()
isn't outputted at all.go-pty/examples/shell/main.go
Lines 37 to 47 in 0dbd56c
I tried to play with the arguments to the IO functions and replace
os.Std*
with a handle toptmx.Name()
, and that got the shell to seem to not use the current TTY, but I still can't seem to do anything at all inside thescreen
connected toptmx.Name()
. No data echos no matter what I type (stty
shows echo enabled though), and typingexit
doesn't seem to reachbash
because it doesn't exit.I feel like I can't be far off at all from getting this to work, but I can't figure out what I'm missing. I'm also confused as to how the shell example was supposed to work in the first place. If you could point me in the right direction I'd really appreciate it.
Thanks so much
The text was updated successfully, but these errors were encountered: