本文整理汇总了Golang中github.com/burke/zeus/go/unixsocket.Usock.WriteFD方法的典型用法代码示例。如果您正苦于以下问题:Golang Usock.WriteFD方法的具体用法?Golang Usock.WriteFD怎么用?Golang Usock.WriteFD使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/burke/zeus/go/unixsocket.Usock
的用法示例。
在下文中一共展示了Usock.WriteFD方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: sendTTYToCommand
func sendTTYToCommand(commandUsock *unixsocket.Usock, clientFile *os.File, err error) error {
if err != nil {
return err
}
return commandUsock.WriteFD(int(clientFile.Fd()))
}
示例2: sendCommandLineArguments
func sendCommandLineArguments(usock *unixsocket.Usock, args []string) error {
master, slave, err := unixsocket.Socketpair(syscall.SOCK_STREAM)
if err != nil {
return err
}
usock.WriteFD(int(slave.Fd()))
if err != nil {
return err
}
slave.Close()
go func() {
defer master.Close()
argAsBytes := []byte{}
for _, arg := range args[1:] {
argAsBytes = append(argAsBytes, []byte(arg)...)
argAsBytes = append(argAsBytes, byte(0))
}
_, err = master.Write(argAsBytes)
if err != nil {
slog.ErrorString("Could not send arguments across: " +
err.Error() + "\r")
return
}
}()
return nil
}
示例3: sendClientPidAndArgumentsToCommand
func sendClientPidAndArgumentsToCommand(commandUsock *unixsocket.Usock, clientPid int, argCount int, argFD int, err error) error {
if err != nil {
return err
}
msg := messages.CreatePidAndArgumentsMessage(clientPid, argCount)
_, err = commandUsock.WriteMessage(msg)
if err != nil {
return err
}
return commandUsock.WriteFD(argFD)
}