syscall: What does syscall.Sysinfo_t.Procs mean?

I’m a little confused about the output of following code, anyone can give a suggestion?

package main

import (
	"fmt"
	"path/filepath"
	"syscall"
)

func main() {
	var info syscall.Sysinfo_t
	syscall.Sysinfo(&info)
	fmt.Println("procs : ", info.Procs)

	if files, err := filepath.Glob("/proc/[0-9]*"); err == nil {
		fmt.Println("procs : ", len(files))
	}
}

The output is:

root@ubuntu-xenial:/home/ubuntu# ./main
procs :  140
procs :  120

/proc on a GNU/Linux machine is a psuedo-filesystem containing information about running processes and the GNU/Linux kernel.

Read more here http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/proc.html

Edit: I realise I’m a bit too sleepy here. What exactly are you asking? Why the number is different? There are things in /proc that do not match your regular expression.

Edit2: But the fact that there are things in /proc that does not match your regular expression is not the answer. I’m not sure what is, but I am getting different number on my machine as well, even when I changed the regular expression pattern to *

I’d like to know why the number is different?

At a guess, threads vs processes?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.