-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
On Mac, lsof
outputs a warning to stderr
, causing a failure "missing txt data returned by lsof"
#867
Comments
Thanks for this great bug report. We could suppress lsof warnings with There is also some information in this Unix.SE QA, can you confirm the warning goes away with Can you show what's inside the buf variable by printing the content of |
Aha, it is manifesting for me right now. To answer your questions:
gives me the expected output (no panic(err)):
gives me
Hope that helps! Sorry for the delay getting back to you. By the time I saw your reply my repro had disappeared, presumably because the backup had finished. I tried triggering another backup but I couldn't reproduce the issue. It's started happening again just now so I thought I'd jump on it. |
In fact, I can reproduce on Linux, with numerous I will push a PR with the first idea, I don't want to swallow warnings (in case of errors). Thanks for your last message, appreciated. |
…ed by lsof to handle potential warnings
[process][darwin][nocgo] Fix #867 iterate on every lines returned by lsof to handle potential warnings
Thanks for the fix! |
Same as shirou#867, the error being: error strconv.Atoi: parsing " Output information may be incomplete.": invalid syntax
Same as shirou#867, the error being: error strconv.Atoi: parsing " Output information may be incomplete.": invalid syntax
Same as shirou#867, the error being: error strconv.Atoi: parsing " Output information may be incomplete.": invalid syntax
Same as shirou#867, the error being: error strconv.Atoi: parsing " Output information may be incomplete.": invalid syntax
Describe the bug
A call to
process.Exe()
on MacOS with CGO disabled is failing with "missing txt data returned by lsof"When I run
/usr/sbin/lsof -p 60232 -Fpfn
(mirroring whatgopsutil/process/process_darwin_nocgo.go
Line 19 in 987c949
stderr
:The
CommandWithContext
function includesstderr
as well asstdout
:gopsutil/internal/common/common.go
Line 51 in 987c949
stderr
. I would have made a PR but this seems like common code used everywhere, so I don't know what the best policy would be: always ignorestderr
globally or make anotherCommandWithContextStdout
or add parameters or something else.To Reproduce
This requires:
stderr
(probably triggered by an in-progress time machine backup)CGO_ENABLED=0
Expected behavior
$ CGO_ENABLED=0 go run main.go
/bin/bash
/bin/bash
/bin/bash
/bin/bash
Actual behavior
$ CGO_ENABLED=0 go run main.go
panic: missing txt data returned by lsof
goroutine 1 [running]:
main.main()
/Users/djs/go/src/gops/main.go:24 +0x1c2
exit status 2
(Note it works fine with cgo)
Environment (please complete the following information):
ver
]/etc/os-release
and the result ofuname -a
]sw_vers
anduname -a
freebsd-version -k -r -u
anduname -a
]uname -a
]Additional context
No cross-compiling, but CGO is disabled.
The text was updated successfully, but these errors were encountered: