maybe see if the https://github.com/glycerine/bark approach will work for you.
On Wednesday, April 30, 2025 at 6:59:20 PM UTC+1 David Bernecker wrote: > The tool I am working on needs to start a privileged process and wait for > the completion of the new process on both Linux and Windows. To keep the OS > specific code separated, I use exec.Cmd for handling the new process. On > Linux I use the normal exec.Command function to start the process using > pkexec to ask for privileged rights and it works without problems. > > On Windows I use ShellExecuteEx to start the new process with the "runas" > verb (so basically the windows version of sudo that uses windows UAC). This > part also works, and called with the flags SEE_MASK_NOCLOSEPROCESS | > SEE_MASK_NOASYNC ShellExecuteEx already returns the Handle for the new > process. My idea then was to create a exec.Cmd object by hand, and use the > handle for initializing the os.Process object that is part of the exec.Cmd > object. However, the newHandleProcess in os that I would need to call is > not exported. > I also can't use the exported FindProcess function in os, because it tries > to get the handle of the privileged process with access rights that my > parent process does not possess... > My current workaround is to use go:linkname to define a NewProcess > function in my code that is linked against the unexported newHandleProcess > function in os. > > This approach does work, but I dislike having to use go:linkname... Any > ideas how I could achieve my goal without it? > > Thanks in advance, > David > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/c31833c7-e048-4651-b008-d5633d3c8509n%40googlegroups.com.