mirror of https://gogs.blitter.com/RLabs/xs
(issue #33) use of time.Sleep() prior to ptmx.Close() in xsd.runShellAs()
Hack to enable server to complete sending data to client (eg. xs -x "ls /foo" losing end of output)
This commit is contained in:
parent
bd0b48d98f
commit
9ca5ccae32
10
xsd/xsd.go
10
xsd/xsd.go
|
@ -327,6 +327,16 @@ func runShellAs(who, hname, ttype, cmd string, interactive bool, //nolint:funlen
|
|||
// #gv:s/label=\"runShellAs\$1\"/label=\"deferPtmxClose\"/
|
||||
defer func() {
|
||||
//logger.LogDebug(fmt.Sprintf("[Exited process was %d]", c.Process.Pid))
|
||||
|
||||
//Ensure socket has sent all data to client prior to closing
|
||||
//NOTE: This is not ideal, as it would be better to somehow
|
||||
//determine if there is any pending outgoing (write) data to the
|
||||
//underlying socket (TCP/KCP) prior to closing; however Go's net pkg
|
||||
//completely hides lower-level stuff. net.Conn.Close() according to
|
||||
//docs sends written data in the background, so how best to determine
|
||||
//all data has been sent? -rlm 2022-10-04
|
||||
|
||||
time.Sleep(100 * time.Millisecond) //Empirically determined :^/
|
||||
_ = ptmx.Close()
|
||||
}()
|
||||
|
||||
|
|
Loading…
Reference in New Issue