You can do it with cgo. I have some code that does this:

// #include <unistd.h>
import "C"

func init() {
        clockTicksPerSec = float64(C.sysconf(C._SC_CLK_TCK))
        if clockTicksPerSec != 100 {
                log.Println("Unusual _SC_CLK_TCK value:", clockTicksPerSec)
        }
}

var clockTicksPerSec float64

// later it normalizes things by clickTicksPerSec

On Thu, Jan 18, 2018 at 5:55 PM,  <andrew.george.hamm...@gmail.com> wrote:
> I want to find out how long a process has been running.
>
> I'm grabbing the starttime out of /proc/$pid/stat for a process. This is in
> "in clock ticks (divide by sysconf(_SC_CLK_TCK))." according to
> http://man7.org/linux/man-pages/man5/proc.5.html
>
> I also have Sysinfo.Uptime (seconds since boot). My plan was to subtract
> proc starttime from uptime, but I need to first divide out the clock tick /
> second to get my units right. I haven't been able to find a way to get this
> value.
>
> I suspect that my approach is wrong and that there is probably a more
> elegant way to do this.
>
> A
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to