Re: [go-nuts] golang poll/epoll/select

2016-06-27 Thread Konstantin Khomoutov
On Mon, 27 Jun 2016 06:26:59 -0700 (PDT) Michael Soulier wrote: > > Hmm. Maybe I misunderstand how runsv connects the two. A simple > > shell test seems to behave more as expected. I'll need to dig. > > > I think I found it. On read I'm getting "resource temporarily > unavailable", so I suspect r

Re: [go-nuts] golang poll/epoll/select

2016-06-27 Thread Michael P. Soulier
On 2016-06-27 11:26 AM, Ian Lance Taylor wrote: > The golang.org/x/sys/unix package support Poll on GNU/Linux. For now I'm using select so it works on darwin too. Seems to work so far. Thanks, Mike -- You received this message because you are subscribed to the Google Groups "golang-nuts" grou

Re: [go-nuts] golang poll/epoll/select

2016-06-27 Thread Ian Lance Taylor
On Mon, Jun 27, 2016 at 6:26 AM, Michael Soulier wrote: > On Saturday, June 25, 2016 at 9:03:59 PM UTC-4, Michael Soulier wrote: >> >> Hmm. Maybe I misunderstand how runsv connects the two. A simple shell test >> seems to behave more as expected. I'll need to dig. >> > > I think I found it. On rea

Re: [go-nuts] golang poll/epoll/select

2016-06-27 Thread Michael Soulier
On Saturday, June 25, 2016 at 9:03:59 PM UTC-4, Michael Soulier wrote: > > Hmm. Maybe I misunderstand how runsv connects the two. A simple shell test > seems to behave more as expected. I'll need to dig. > > I think I found it. On read I'm getting "resource temporarily unavailable", so I suspect

Re: [go-nuts] golang poll/epoll/select

2016-06-25 Thread Michael Soulier
On Saturday, June 25, 2016 at 8:53:53 PM UTC-4, Michael Soulier wrote: > > Unfortunately not. runsv starts the logger and connects the service's > stdout to the logger's stdin. It opens this pipe even if the service isn't > up yet, so when you read from stdin, it immediately returns with an EOF,

Re: [go-nuts] golang poll/epoll/select

2016-06-25 Thread Dave Cheney
That doesn't sound right. Reading from a pipe should only get EOF when the other side of the pipe is closed. On Sunday, 26 June 2016 10:53:53 UTC+10, Michael Soulier wrote: > > On Saturday, June 25, 2016 at 4:19:34 PM UTC-4, Janne Snabb wrote: >> >> You should not be using select in the first pla

Re: [go-nuts] golang poll/epoll/select

2016-06-25 Thread Michael Soulier
On Saturday, June 25, 2016 at 4:19:34 PM UTC-4, Janne Snabb wrote: > > You should not be using select in the first place. You are making things > complicated for no reason whatsoever. (If I understand your intention > correctly.) > > You should just read from os.Stdin. It will block until there

Re: [go-nuts] golang poll/epoll/select

2016-06-25 Thread Janne Snabb
On 2016-06-25 22:59, Michael Soulier wrote: > I'm curious as to what I'm doing wrong with select here, and if it's > possible to do this with a goroutine like you describe. You should not be using select in the first place. You are making things complicated for no reason whatsoever. (If I understa

Re: [go-nuts] golang poll/epoll/select

2016-06-25 Thread Michael Soulier
On Saturday, June 25, 2016 at 11:31:57 AM UTC-4, Jessta wrote: > > You'll only get an EOF if the file descriptor has been closed, if it's > closed then you're not going to be able to read anything more anyway. > > What are you trying to do? > I'm trying to write a replacement for svlogd from th

Re: [go-nuts] golang poll/epoll/select

2016-06-25 Thread Jesse McNelis
On 25 Jun 2016 11:08 p.m., "Michael Soulier" wrote: > > Sure, but when you read and get an EOF you return immediately, so the goroutine would be busy waiting when there's nothing to read, would it not? > You'll only get an EOF if the file descriptor has been closed, if it's closed then you're not

Re: [go-nuts] golang poll/epoll/select

2016-06-25 Thread Michael Soulier
On Friday, June 24, 2016 at 6:59:28 PM UTC-4, Ian Lance Taylor wrote: > > In Go you normally simply start a goroutine that reads from Stdin and > sends the data over a channel. > > Goroutines are cheap. > > Sure, but when you read and get an EOF you return immediately, so the goroutine would

Re: [go-nuts] golang poll/epoll/select

2016-06-25 Thread Michael Soulier
I thought I got select working but now it's returning immediately even without any input to stdin. // loop forever - we expect to be killed with a SIGTERM or SIGINT for { logger.Debug("going into select on stdin") var r_fdset syscall.FdSet for i := 0; i < 16; i++ {

Re: [go-nuts] golang poll/epoll/select

2016-06-25 Thread Michael Soulier
On Friday, June 24, 2016 at 7:10:55 PM UTC-4, graha...@gmail.com wrote: > > If you have a specific case that isn't covered by blocking in a > go-routine, you can always use the syscall's directly, with a very similar > API to what you would do in C. > > For example here's the epoll ones in stdli

Re: [go-nuts] golang poll/epoll/select

2016-06-24 Thread graham4king
If you have a specific case that isn't covered by blocking in a go-routine, you can always use the syscall's directly, with a very similar API to what you would do in C. For example here's the epoll ones in stdlib: https://golang.org/pkg/syscall/#EpollCreate New syscall wrappers are in the x/

Re: [go-nuts] golang poll/epoll/select

2016-06-24 Thread Ian Lance Taylor
On Fri, Jun 24, 2016 at 2:44 PM, wrote: > Unfortunately I don't think this works if you want to do something like poll > stdin, skipping EOFs in a non-busy-waiting pattern. > > A simple poll() in C works fine for this, but I can't figure out how do this > this in Go because it does not provide a

Re: [go-nuts] golang poll/epoll/select

2016-06-24 Thread msoulier
Unfortunately I don't think this works if you want to do something like poll stdin, skipping EOFs in a non-busy-waiting pattern. A simple poll() in C works fine for this, but I can't figure out how do this this in Go because it does not provide a poll. Maybe I'm missing something. Mike On Thu