You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A solution is to set the WaitDelay to ensure wait() returns
// If WaitDelay is non-zero, the command's I/O pipes will be closed after
// WaitDelay has elapsed after either the command's process has exited or
// (if Context is non-nil) Context is done, whichever occurs first.
// If the command's process is still running after WaitDelay has elapsed,
// it will be terminated with os.Kill before the pipes are closed.
//
// If the command exits with a success code after pipes are closed due to
// WaitDelay and no Interrupt signal has been sent, Wait and similar methods
// will return ErrWaitDelay instead of nil.
//
// If WaitDelay is zero (the default), I/O pipes will be read until EOF,
// which might not occur until orphaned subprocesses of the command have
// also closed their descriptors for the pipes.
WaitDelay time.Duration
To Reproduce
the following should block indefinitely
common.Invoke{}.Command("bash", "-c", "watch date > date.txt 2>&1")
Expected behavior
The command above should be terminated if the Timeout is exceeded
Environment (please complete the following information):
Windows: [paste the result of ver]
Linux: [paste contents of /etc/os-release and the result of uname -a]
Mac OS: [paste the result of sw_vers and uname -a
FreeBSD: [paste the result of freebsd-version -k -r -u and uname -a]
OpenBSD: [paste the result of uname -a]
Additional context
[Cross-compiling? Paste the command you are using to cross-compile and the result of the corresponding go env]
The text was updated successfully, but these errors were encountered:
That is why we introduced xxxWithContext. We can avoid waiting indefinitely by setting a timeout for a context . Further, as the author of the library, we cannot set the appropriate wait time. Therefore, we provide a way for library users to set a timeout.
Describe the bug
The problem lies in how the commands are spawned in the Invoker
gopsutil/internal/common/common.go
Line 50 in 6100124
if the spawned command opens I/Os, the
wait()
could block indefinitely. This bug has been reported in many issues with go : golang/go#24050 golang/go#20730 golang/go#23019 golang/go#56187 golang/go#57129 golang/go#60309 golang/go#22485A solution is to set the WaitDelay to ensure wait() returns
To Reproduce
the following should block indefinitely
Expected behavior
The command above should be terminated if the Timeout is exceeded
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
[Cross-compiling? Paste the command you are using to cross-compile and the result of the corresponding
go env
]The text was updated successfully, but these errors were encountered: