Re: [go-nuts] An old problem: lack of priority select cases

2019-08-30 Thread roger peppe
The reason you're wanting priority select is because you are shutting down the data channel preemptively, but you can wait for an acknowledgement from the run goroutine instead: https://play.golang.org/p/qSWluYy4ifl On Wed, 28 Aug 2019 at 18:06, T L wrote: > The old thread: > https://groups.go

Re: [go-nuts] Help understanding mapping Go<->C structures across IOCTL's

2019-08-30 Thread George Hartzell
George Hartzell writes: > [...] > ``` > i2c/i2c.go:15:9: cannot use &buf[0] (type *byte) as type *_Ctype_uchar > in assignment > ``` > > I can't come up with any cast that makes the compiler happy. I'm also > unsure whether that line runs afoul of this commandment: *Go code may > not sto

Re: [go-nuts] Help understanding mapping Go<->C structures across IOCTL's

2019-08-30 Thread Ian Lance Taylor
On Fri, Aug 30, 2019 at 4:57 PM George Hartzell wrote: > > Ian Lance Taylor writes: > > On Thu, Aug 29, 2019 at 6:26 PM George Hartzell > wrote: > > [...] > > There is another approach, which is to use import "C", and then write code > like > > > > const IoctlConstant = C.IoctlConstant >

Re: [go-nuts] Help understanding mapping Go<->C structures across IOCTL's

2019-08-30 Thread George Hartzell
Ian Lance Taylor writes: > On Thu, Aug 29, 2019 at 6:26 PM George Hartzell wrote: > [...] > There is another approach, which is to use import "C", and then write code > like > > const IoctlConstant = C.IoctlConstant > type GoIoctlType = C.CIoctlType > > and then use those types in code

Re: [go-nuts] Help understanding mapping Go<->C structures across IOCTL's

2019-08-30 Thread Ian Lance Taylor
On Thu, Aug 29, 2019 at 6:26 PM George Hartzell wrote: > > I suppose I *could* write a cgo library that would wrap the C-based > [i2c-tools] library, but I wanted to do it directly in Go, without > adding the [i2c-tools] dependency. > > Or, are you saying that I should create a package that does t

Re: [go-nuts] An old problem: lack of priority select cases

2019-08-30 Thread Robert Engels
You changed the Read() method incorrectly - it should be using the Read lock, not the Write lock.Still, as I pointed out when I posted it, Play has a problem where it aborts if all routines are sleeping (not just blocked), so you need to run it locally.-Original Message- From: T L Sent: Au

Re: [go-nuts] An old problem: lack of priority select cases

2019-08-30 Thread T L
On Friday, August 30, 2019 at 12:39:41 PM UTC-4, Robert Engels wrote: > > > Makes no difference in the code I posted as long as they all use the > same MultiWriterChannel. In fact, others can be late started, as they will > fail fast if the channel is already closed. > https://play.golang.

Re: [go-nuts] An old problem: lack of priority select cases

2019-08-30 Thread Robert Engels
Makes no difference in the code I posted as long as they all use the same MultiWriterChannel. In fact, others can be late started, as they will fail fast if the channel is already closed.-Original Message- From: T L Sent: Aug 30, 2019 11:13 AM To: golang-nuts Subject: Re: [go-nuts] An

Re: [go-nuts] An old problem: lack of priority select cases

2019-08-30 Thread T L
On Friday, August 30, 2019 at 10:35:29 AM UTC-4, Robert Engels wrote: > > I don't think so. Why do you think that is the case? The RWLock is "fair" > in the sense that once the 'closer' attempts to get the lock, it is > guaranteed to get it (as the code is structured) - the subsequent readers

Re: [go-nuts] An old problem: lack of priority select cases

2019-08-30 Thread Robert Engels
I don't think so. Why do you think that is the case? The RWLock is "fair" in the sense that once the 'closer' attempts to get the lock, it is guaranteed to get it (as the code is structured) - the subsequent readers will queue behind the "writer = closer".-Original Message- From: T L Sent:

Re: [go-nuts] An old problem: lack of priority select cases

2019-08-30 Thread T L
@Robert I think there is a difference between the code of @Leo and you. In you code, the Wirte/Read/Close are all possible to block for ever. On Thursday, August 29, 2019 at 8:59:10 PM UTC-4, Robert Engels wrote: > > > Oops. You are right. The original used two different methods Closed() and > R

Re: [go-nuts] How to execute a command using root?

2019-08-30 Thread Kevin Chadwick
On 8/30/19 7:49 AM, Benjamin wrote: > Do anyone have any suggestions on this? Thanks Sudo is an option. I prefer to have a master root process that spawns workers processes that drop privileges via setegid...seteuid... syscalls to dedicated users for various tasks. Takes concurrency to the next le

[go-nuts] Why HeapInuse - HeapReleased is greater than "used" memory returned by "free" util?

2019-08-30 Thread Sergey Naumov
Hello. I've originally asked this question on StackOverflow: https://stackoverflow.com/questions/57714300/ho-to-properly-interpret-heapinuse-heapidle-heapreleased-memory-stats-in-gol So here I will write just a quick summary: I monitor memory usage of my program to determine memory pressure con

Re: [go-nuts] How to execute a command using root?

2019-08-30 Thread Benjamin
Yes, it works. Thank you very much! 在 2019年8月30日星期五 UTC+8下午2:56:50,Jakob Borg写道: > > On 30 Aug 2019, at 08:49, Benjamin > > wrote: > > > Then I tried to use "sudo" to execute the command, but the environment > variables can't be carried over into the command; > > > This is a sudo configuration i