mirror of
https://github.com/golang/go
synced 2024-11-24 21:00:09 -07:00
exp/ssh: export type signal. Renamed to Signal
R=dave, agl, rsc, golang-dev, n13m3y3r CC=golang-dev https://golang.org/cl/5450059
This commit is contained in:
parent
c52b7db470
commit
fad57c0c03
@ -15,39 +15,39 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
type signal string
|
type Signal string
|
||||||
|
|
||||||
// POSIX signals as listed in RFC 4254 Section 6.10.
|
// POSIX signals as listed in RFC 4254 Section 6.10.
|
||||||
const (
|
const (
|
||||||
SIGABRT signal = "ABRT"
|
SIGABRT Signal = "ABRT"
|
||||||
SIGALRM signal = "ALRM"
|
SIGALRM Signal = "ALRM"
|
||||||
SIGFPE signal = "FPE"
|
SIGFPE Signal = "FPE"
|
||||||
SIGHUP signal = "HUP"
|
SIGHUP Signal = "HUP"
|
||||||
SIGILL signal = "ILL"
|
SIGILL Signal = "ILL"
|
||||||
SIGINT signal = "INT"
|
SIGINT Signal = "INT"
|
||||||
SIGKILL signal = "KILL"
|
SIGKILL Signal = "KILL"
|
||||||
SIGPIPE signal = "PIPE"
|
SIGPIPE Signal = "PIPE"
|
||||||
SIGQUIT signal = "QUIT"
|
SIGQUIT Signal = "QUIT"
|
||||||
SIGSEGV signal = "SEGV"
|
SIGSEGV Signal = "SEGV"
|
||||||
SIGTERM signal = "TERM"
|
SIGTERM Signal = "TERM"
|
||||||
SIGUSR1 signal = "USR1"
|
SIGUSR1 Signal = "USR1"
|
||||||
SIGUSR2 signal = "USR2"
|
SIGUSR2 Signal = "USR2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// A Session represents a connection to a remote command or shell.
|
// A Session represents a connection to a remote command or shell.
|
||||||
type Session struct {
|
type Session struct {
|
||||||
// Stdin specifies the remote process's standard input.
|
// Stdin specifies the remote process's standard input.
|
||||||
// If Stdin is nil, the remote process reads from an empty
|
// If Stdin is nil, the remote process reads from an empty
|
||||||
// bytes.Buffer.
|
// bytes.Buffer.
|
||||||
Stdin io.Reader
|
Stdin io.Reader
|
||||||
|
|
||||||
// Stdout and Stderr specify the remote process's standard
|
// Stdout and Stderr specify the remote process's standard
|
||||||
// output and error.
|
// output and error.
|
||||||
//
|
//
|
||||||
// If either is nil, Run connects the corresponding file
|
// If either is nil, Run connects the corresponding file
|
||||||
// descriptor to an instance of ioutil.Discard. There is a
|
// descriptor to an instance of ioutil.Discard. There is a
|
||||||
// fixed amount of buffering that is shared for the two streams.
|
// fixed amount of buffering that is shared for the two streams.
|
||||||
// If either blocks it may eventually cause the remote
|
// If either blocks it may eventually cause the remote
|
||||||
// command to block.
|
// command to block.
|
||||||
Stdout io.Writer
|
Stdout io.Writer
|
||||||
Stderr io.Writer
|
Stderr io.Writer
|
||||||
@ -130,7 +130,7 @@ type signalMsg struct {
|
|||||||
|
|
||||||
// Signal sends the given signal to the remote process.
|
// Signal sends the given signal to the remote process.
|
||||||
// sig is one of the SIG* constants.
|
// sig is one of the SIG* constants.
|
||||||
func (s *Session) Signal(sig signal) error {
|
func (s *Session) Signal(sig Signal) error {
|
||||||
req := signalMsg{
|
req := signalMsg{
|
||||||
PeersId: s.peersId,
|
PeersId: s.peersId,
|
||||||
Request: "signal",
|
Request: "signal",
|
||||||
@ -170,9 +170,9 @@ func (s *Session) Start(cmd string) error {
|
|||||||
return s.start()
|
return s.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run runs cmd on the remote host and waits for it to terminate.
|
// Run runs cmd on the remote host and waits for it to terminate.
|
||||||
// Typically, the remote server passes cmd to the shell for
|
// Typically, the remote server passes cmd to the shell for
|
||||||
// interpretation. A Session only accepts one call to Run,
|
// interpretation. A Session only accepts one call to Run,
|
||||||
// Start or Shell.
|
// Start or Shell.
|
||||||
func (s *Session) Run(cmd string) error {
|
func (s *Session) Run(cmd string) error {
|
||||||
err := s.Start(cmd)
|
err := s.Start(cmd)
|
||||||
@ -182,7 +182,7 @@ func (s *Session) Run(cmd string) error {
|
|||||||
return s.Wait()
|
return s.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shell starts a login shell on the remote host. A Session only
|
// Shell starts a login shell on the remote host. A Session only
|
||||||
// accepts one call to Run, Start or Shell.
|
// accepts one call to Run, Start or Shell.
|
||||||
func (s *Session) Shell() error {
|
func (s *Session) Shell() error {
|
||||||
if s.started {
|
if s.started {
|
||||||
@ -331,7 +331,7 @@ func (s *Session) stderr() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// StdinPipe returns a pipe that will be connected to the
|
// StdinPipe returns a pipe that will be connected to the
|
||||||
// remote command's standard input when the command starts.
|
// remote command's standard input when the command starts.
|
||||||
func (s *Session) StdinPipe() (io.WriteCloser, error) {
|
func (s *Session) StdinPipe() (io.WriteCloser, error) {
|
||||||
if s.Stdin != nil {
|
if s.Stdin != nil {
|
||||||
@ -346,11 +346,11 @@ func (s *Session) StdinPipe() (io.WriteCloser, error) {
|
|||||||
return pw, nil
|
return pw, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// StdoutPipe returns a pipe that will be connected to the
|
// StdoutPipe returns a pipe that will be connected to the
|
||||||
// remote command's standard output when the command starts.
|
// remote command's standard output when the command starts.
|
||||||
// There is a fixed amount of buffering that is shared between
|
// There is a fixed amount of buffering that is shared between
|
||||||
// stdout and stderr streams. If the StdoutPipe reader is
|
// stdout and stderr streams. If the StdoutPipe reader is
|
||||||
// not serviced fast enought it may eventually cause the
|
// not serviced fast enought it may eventually cause the
|
||||||
// remote command to block.
|
// remote command to block.
|
||||||
func (s *Session) StdoutPipe() (io.ReadCloser, error) {
|
func (s *Session) StdoutPipe() (io.ReadCloser, error) {
|
||||||
if s.Stdout != nil {
|
if s.Stdout != nil {
|
||||||
@ -365,11 +365,11 @@ func (s *Session) StdoutPipe() (io.ReadCloser, error) {
|
|||||||
return pr, nil
|
return pr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// StderrPipe returns a pipe that will be connected to the
|
// StderrPipe returns a pipe that will be connected to the
|
||||||
// remote command's standard error when the command starts.
|
// remote command's standard error when the command starts.
|
||||||
// There is a fixed amount of buffering that is shared between
|
// There is a fixed amount of buffering that is shared between
|
||||||
// stdout and stderr streams. If the StderrPipe reader is
|
// stdout and stderr streams. If the StderrPipe reader is
|
||||||
// not serviced fast enought it may eventually cause the
|
// not serviced fast enought it may eventually cause the
|
||||||
// remote command to block.
|
// remote command to block.
|
||||||
func (s *Session) StderrPipe() (io.ReadCloser, error) {
|
func (s *Session) StderrPipe() (io.ReadCloser, error) {
|
||||||
if s.Stderr != nil {
|
if s.Stderr != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user