services/device/deviced/internal/impl: rework how instance stops happen

The motivation for the change was that apps (that have the restart
policy set) would get restarted if they fail to stop cleanly (so if
stopAppRemotely fails but the app exits -- either on its own or due to
forceSuspend -- the reaper would immediately go ahead and restart it).
Even if the app exits cleanly with a remote stop, there's still the
chance of a race between the stopWatching call and the reaper running
the poll loop and restarting the app.

This CL does a few things:

- tells the reaper to stop watching the app when we intend to kill
  it (to prevent future restarts)

- adds logic to stop() to verify when the app process actually exited,
  and call forceSuspend only if it didn't.  Also, Kill now returns an
  error iff the app process didn't die (and conversely, if Kill returns
  nil, the user can be confident that the app has died).  The app
  transitions to state 'not running' iff the process died.

- make forciblySuspend work even for instances not watched by the reaper

- addresses a TODO in restartAppIfNecessary

Change-Id: I7f946a5967b0f34be5213477438dafdae9e0d121
3 files changed
tree: e1b3e404e8186b879d7a472c20bebf21b57e49eb
  1. cmd/
  2. examples/
  3. internal/
  4. lib/
  5. runtime/
  6. services/
  7. test/
  8. .gitignore
  9. AUTHORS
  10. CONTRIBUTING.md
  11. CONTRIBUTORS
  12. envvar.go
  13. envvar_test.go
  14. LICENSE
  15. PATENTS
  16. README.md
  17. VERSION
README.md

Vanadium

This repository contains a reference implementation of the Vanadium APIs.

Unlike the APIs in https://github.com/vanadium/go.v23, which promises to provide backward compatibility this repository makes no such promises.