Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syscall: What does syscall.Sysinfo_t.Procs mean? #23438

Closed
k82cn opened this issue Jan 13, 2018 · 6 comments
Closed

syscall: What does syscall.Sysinfo_t.Procs mean? #23438

k82cn opened this issue Jan 13, 2018 · 6 comments

Comments

@k82cn
Copy link

k82cn commented Jan 13, 2018

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

What version of Go are you using (go version)?

go version go1.9.2 linux/amd64

Does this issue reproduce with the latest release?

should be

What operating system and processor architecture are you using (go env)?

GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build248288577=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

xref kubernetes/kubernetes#57136

@AlexRouSg
Copy link
Contributor

AlexRouSg commented Jan 13, 2018

It's the same as calling sysinfo in C.
https://play.golang.org/p/X6OYwjQn0BU - will not run in playground

http://man7.org/linux/man-pages/man2/sysinfo.2.html

EDIT: Forgot to add, on linux, every thread is considered a process so you can say sysinfo.procs is how many threads are running

@agnivade
Copy link
Contributor

Hi,

The Go project does not use its bug tracker for general discussion or asking questions about the language. The Github bug tracker is only used for tracking bugs and proposals going through the Proposal Process.

Please see the Questions wiki page; it has a list of good places for asking questions. Thanks!

@odeke-em
Copy link
Member

@k82cn please check out the places that @agnivade recommended asking questions on and thank you @agnivade!

@mikioh mikioh changed the title What does syscall.Sysinfo_t.Procs means? syscall: What does syscall.Sysinfo_t.Procs means? Jan 13, 2018
@mikioh mikioh changed the title syscall: What does syscall.Sysinfo_t.Procs means? syscall: What does syscall.Sysinfo_t.Procs mean? Jan 13, 2018
@k82cn
Copy link
Author

k82cn commented Jan 14, 2018

@odeke-em , got that, thanks very much :).

@odeke-em
Copy link
Member

Thank you @k82cn! Actually your issue reminded me of #4318 -- an issue that's still open, focused on how under-documented the syscall package is. I believe that if we had documented it, you'd easily get the answer.

If interested in helping to solve that issue, once you get some answers, please feel free to send some patches documenting syscall.SysInfo and the struct; it would be a great contribution for future self and to others, we'll be grateful.

@k82cn
Copy link
Author

k82cn commented Jan 14, 2018

sure; I'd like to help it :).

@golang golang locked and limited conversation to collaborators Jan 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants