aboutsummaryrefslogtreecommitdiff
path: root/src/os/exec_unix_test.go
AgeCommit message (Collapse)Author
2024-07-17os: don't try to signal PID -1 on UnixIan Lance Taylor
This restores behavior that we lost in CL 588675. Fixes #68496 Change-Id: I1740986bed647835986d54109071b7a6b37413d5 Reviewed-on: https://go-review.googlesource.com/c/go/+/599015 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com>
2024-06-11os: always return syscall.ECHILD from Wait for done processMichael Pratt
For processes that don't exist at lookup time, CL 570036 and CL 588675 make Wait return unconditionally return ErrProcessDone when using pidfd, rather than attempting to make a wait system call. This is consistent with Signal/Kill, but inconsistent with the previous behavior of Wait, which would pass through the kernel error, syscall.ECHILD. Switch the ErrProcessDone case to return syscall.ECHILD instead for consistency with previous behavior. That said, I do think a future release should consider changing ECHILD to ErrProcessDone in all cases (including when making an actual wait system call) for better consistency with Signal/Kill/FindProcess. Fixes #67926. Cq-Include-Trybots: luci.golang.try:gotip-darwin-amd64_14,gotip-solaris-amd64,gotip-openbsd-amd64 Change-Id: I1f688a5751d0f3aecea99c3a5b35c7894cfc2beb Reviewed-on: https://go-review.googlesource.com/c/go/+/591816 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Kirill Kolyshkin <kolyshkin@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-05-21os: make FindProcess use pidfd on LinuxKir Kolyshkin
This is a continuation of CL 570036. Amend FindProcess to use pidfdFind, and make it return a special Process with Pid of pidDone (-2) if the process is not found. Amend Wait and Signal to return ErrProcessDone if pid == pidDone. The alternative to the above would be to make FindProcess return ErrProcessDone, but this is unexpected and incompatible API change, as discussed in #65866 and #51246. For #62654. Rework of CL 542699 (which got reverted in CL 566476). Change-Id: Ifb4cd3ad1433152fd72ee685d0b85d20377f8723 Reviewed-on: https://go-review.googlesource.com/c/go/+/570681 TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Kirill Kolyshkin <kolyshkin@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-08-07os: use t.Fatalf instead of t.Errorf in TestErrProcessDoneJes Cok
If err is non-nil, use t.Fatalf to avoid panic when calling p.Wait(). Change-Id: Ief4e43ba5ad782999063941ed3b12f3fe4d93621 GitHub-Last-Rev: 5d32b3c082e54a914360cb4434d4cc7682e7031e GitHub-Pull-Request: golang/go#61740 Reviewed-on: https://go-review.googlesource.com/c/go/+/515655 Run-TryBot: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Rob Pike <r@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-06-17os/exec: document a method to check if a process is aliveMoritz Poldrack
Fixes #34396 Change-Id: I35c4e3447f84e349adf7edba92ccb19b324bfe14 GitHub-Last-Rev: 4f06764109ddd9bdfbe4841fc1bebebe026eeb29 GitHub-Pull-Request: golang/go#60763 Reviewed-on: https://go-review.googlesource.com/c/go/+/502815 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-01-19os: clean up testsBryan C. Mills
- Use testenv.Command instead of exec.Command to try to get more useful timeout behavior. - Parallelize tests that appear not to require global state. (And add explanatory comments for a few that are not parallelizable for subtle reasons.) - Consolidate some “Helper” tests with their parent tests. - Use t.TempDir instead of os.MkdirTemp when appropriate. - Factor out subtests for repeated test helpers. For #36107. Updates #22315. Change-Id: Ic24b6957094dcd40908a59f48e44c8993729222b Reviewed-on: https://go-review.googlesource.com/c/go/+/458015 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com>
2022-03-29all: use new "unix" build tag where appropriateIan Lance Taylor
For #20322 For #51572 Change-Id: Id0b4799d097d01128e98ba4cc0092298357bca45 Reviewed-on: https://go-review.googlesource.com/c/go/+/389935 Trust: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-10-28all: go fix -fix=buildtag std cmd (except for bootstrap deps, vendor)Russ Cox
When these packages are released as part of Go 1.18, Go 1.16 will no longer be supported, so we can remove the +build tags in these files. Ran go fix -fix=buildtag std cmd and then reverted the bootstrapDirs as defined in src/cmd/dist/buildtool.go, which need to continue to build with Go 1.4 for now. Also reverted src/vendor and src/cmd/vendor, which will need to be updated in their own repos first. Manual changes in runtime/pprof/mprof_test.go to adjust line numbers. For #41184. Change-Id: Ic0f93f7091295b6abc76ed5cd6e6746e1280861e Reviewed-on: https://go-review.googlesource.com/c/go/+/344955 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-02-20all: go fmt std cmd (but revert vendor)Russ Cox
Make all our package sources use Go 1.17 gofmt format (adding //go:build lines). Part of //go:build change (#41184). See https://golang.org/design/draft-gobuild Change-Id: Ia0534360e4957e58cd9a18429c39d0e32a6addb4 Reviewed-on: https://go-review.googlesource.com/c/go/+/294430 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-10-31os: export errFinished as ErrProcessDoneColin Arnott
(*Process).Signal returns an error sentinel, previously errFinished, when (*Process).done or syscall.ESRCH. Callers would like the ability to test for this state, so the value has been exported as ErrProcessDone. Fixes #39444 Change-Id: I510e7647cc032af290180de5149f35ab7b09a526 Reviewed-on: https://go-review.googlesource.com/c/go/+/242998 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Trust: Tobias Klauser <tobias.klauser@gmail.com>