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 [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 store

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

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

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:

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. >

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]

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

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 >

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

[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

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

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

2019-08-30 Thread Jakob Borg
On 30 Aug 2019, at 08:49, Benjamin mailto:wangchao.nlp@gmail.com>> 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 issue. See sudo --preserve-env etc. Best regards, Jakob -- You

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

2019-08-30 Thread Jan Mercl
On Fri, Aug 30, 2019 at 8:53 AM Jan Mercl <0xj...@gmail.com> wrote: > Moreover, it should not be possible. But whitelisting certain users to run certain programs using sudo, but no password, is possible. -- You received this message because you are subscribed to the Google Groups

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

2019-08-30 Thread Jan Mercl
On Fri, Aug 30, 2019 at 8:49 AM Benjamin wrote: >Do anyone have any suggestions on this? Thanks. IINM, what you want is not possible. Moreover, it should not be possible. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from

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

2019-08-30 Thread Benjamin
Hi, I need to execute a couple of commands in golang, the code is roughly as below, cmd := exec.Command(executable, newArgs...) if env != nil && len(env) > 0 { cmd.Env = env } outMsg, err := cmd.CombinedOutput() if err != nil { .. } Executing the